ass3- solution

# ass3- 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 3 Question 1 n temp (a) data subset1; set A3Q1.largedata; where (x2 > =20 and x2 < 60); keep x1-x5; run; (b) data subset2; set A3Q1.largedata; where ((x2 > =60 and x1 < 20) or (x3 > 21 and x3 < 67)); keep x3-x8; run; (c) data subset3; set A3Q1.largedata; if (x6 > x7) then y1 = 1; else y1 = 0; y2 = sum(of x8-x18); if y1=1 and y2 > 700; keep x1-x5; run; (d) data subset4; set A3Q1.largedata(firstobs=55 obs=305); if (x6 > x7) then y1 = 1; else y1 = 0; if y1=0 and x1 > 60; drop x40 x45 x50; run; (e) data subset5; set A3Q1.largedata; if (x6 > x7) then y1 = 1; else y1 = 0; 1

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

View Full Document
y2 = sum(of x8-x18); if x1 > 70 and y2 < 300; run; data subset6; set A3Q1.largedata; if (x6 > x7) then y1 = 1; else y1 = 0; y2 = sum(of x8-x18); if x1 > 65; run; data subset7; set A3Q1.largedata; if (x6 > x7) then y1 = 1; else y1 = 0; if y1 = 0; run; (f) data subset8; set A3Q1.largedata; if (x6 > x7) then y1 = 1; else y1 = 0; y2 = sum(of x8-x18); if x1 < 25 then y3 = 1; else if x1 < 75 and x1 > =25 then y3 = 2; else if x1 > =75 then y3=3; run; proc means data=subset8 noprint; class y1 y3; output out=gmean mean(x2)=mx2 std(x2)=sx2; run; data overall; set gmean(where=(_type_=0)); drop y1 y3 _type_ _freq_; run; data marginal1; set gmean(where=(_type_=1)); drop y1 _type_ _freq_; run; data marginal2; set gmean(where=(_type_=2)); drop y3 _type_ _freq_; run; data group; set gmean(where=(_type_=3)); 2
drop _type_ _freq_; run; Question 2 n temp (a) data demo; set A3Q2.demo1 A3Q2.demo2; run; proc freq data=demo; tables gender; run; Cumulative Cumulative gender Frequency Percent Frequency Percent ----------------------------------------------------------- 0 58 58.00 58 58.00 1 42 42.00 100 100.00 (b) (i) data visit0708; set A3Q2.visit07 A3Q2.visit08; run; proc sort data=visit0708; by id vid; run; (ii) proc sort data=demo; by id; run; data visit0708; merge visit0708(in=d1) demo(keep=id dob in=d2); by id; if d1 and d2; agevisit = yrdif(dob,dvisit,&actual&); run; proc means data=visit0708 mean std; var agevisit sbp dbp; run; 3

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.

## This document was uploaded on 05/04/2011.

### Page1 / 12

ass3- 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