{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ass2- solution

# ass2- solution - UNIVERSITY OF HONG KONG DEPARTMENT OF...

This preview shows pages 1–4. Sign up to view the full content.

UNIVERSITY OF HONG KONG DEPARTMENT OF STATISTICS AND ACTUARIAL SCIENCE STAT1303 DATA MANAGEMENT (SEMESTER 1 2009/2010) Suggested Solutions of Assignment 2 Question 1 (a) libname A2Q1 °d: n temp°; data data2; set A2Q1.data1; if w = ° ° then w = °99°; if x = . then x = 99; if y = . then y = 99; run; (b) data data2; set data2; if x^=99 and y^=99 then z = y - exp(x); run; (c) data data2; set data2; if z > = 20 then t = y - x**2; else t = sqrt(y + x**2); run; (d) data data2; set data2; if upcase(gender) = °M° then gender = °M°; else if upcase(gender) = °F° then gender = °F°; run; (e) data data2; set data2; CID = °C° jj compress(put(id,4.)); run; (f) data data2; set data2; ddob = input(scan(cdob,1,°/°),2.0); 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
mdob = input(scan(cdob,2,°/°),2.0); ydob = input(scan(cdob,3,°/°),4.0); dob = mdy(mdob,ddob,ydob); dvisit = input(scan(cvisit,1,°/°),2.0); mvisit = input(scan(cvisit,2,°/°),2.0); yvisit = input(scan(cvisit,3,°/°),4.0); visit = mdy(mvisit,dvisit,yvisit); visitage = yrdif(dob,visit,°actual°); drop mdob ddob ydob mvisit dvisit yvisit; run; (g) data data2; set data2; if q1= 0 then do; q2 = 99; q3 = °NA°; end; run; (h) proc print data=data2; where (index(upcase(name),°PETER°) > 0); run; Obs name cdob cvisit id gender q1 q2 q3 w 2 Chan Peter 21/4/1998 13/12/2006 1 M 0 99 NA BD 4 peter Chan 3/8/1997 21/9/2005 111 M 0 99 NA BB Obs x y z t CID dob visit visitage 2 35 23 -1.58601E15 35.3270 C1 13990 17148 8.64658 4 15 41 -3268976.37 16.3095 C111 13729 16700 8.13425 Question 2 (a) libname A2Q2 °c: n °; data A2Q2.longterm; infile °c: n longterm.dat° delimiter = °,°; input type adl cognitive burden proximity cdisease; label type =°Long term service type the response receving°; label ad = °Activities of daily living°; label cognitive = °Cognitive impairment°; label burden = °Caregiver burden°; label proximity = °Geographic proximity°; label cdisease = °Number of chronic diseases°; 2
run; (b) (i) proc format; value gburden 999,. = °No answer/Missing° 0 = °No burden° 1 = °Some burden°; run; data A2Q2.longterm; set A2Q2.longterm; format gburden gburden.; if burden > =0 and burden

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 9

ass2- solution - UNIVERSITY OF HONG KONG DEPARTMENT OF...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online