ass2- solution

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

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

View Full Document Right Arrow Icon
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) 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; jj compress(put(id,4.)); run; (f) data data2; set data2; ddob = input(scan(cdob,1,&/&),2.0); 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
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; > 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) n data A2Q2.longterm; 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
Background image of page 2
run; (b) (i) proc format; value gburden 999,. 1 = &Some burden&; run; data A2Q2.longterm; set A2Q2.longterm; format gburden gburden.; if burden > =0 and burden < =60 then gburden = 0; else if burden > 60 then gburden = 1; run; (ii) proc format; value gdisease 99,. 2 = &More than 2&; run; data A2Q2.longterm; set A2Q2.longterm; format gdisease gdisease.; if cdisease = 0 then gdisease = 0; else if cdisease = 1 or cdisease = 2 then gdisease = 1; else if cdisease
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 05/04/2011.

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 Right Arrow Icon
Ask a homework question - tutors are online