ass4- solution

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

This preview shows pages 1–3. 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 4 Question 1 (a) proc sort data=diag; by gender group; run; proc means data=diag; var x; by gender group; output out=mdiag mean=mx; run; (b) (i) proc sort data=mdiag; by gender; run; data mdiagt; array mlist(*) m1-m5; retain m1-m5; set mdiag; by gender; if first.gender then do; do i = 1 to 5; mlist(i)=0; end; end; mlist(group) = mx; if last.gender; drop i; run; data mdiagt; set mdiagt; keep gender m1-m5; run; (ii) proc sort data=mdiagt; by gender; run; proc sort data=diag; 1

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

View Full Document
by gender; run; data diag1; merge diag mdiagt; by gender; array mxlist(*) m1-m5; array dxlist(*) dx1-dx5; do i = 1 to 5; dxlist(i) = x - mxlist(i); end; drop i; run; Question 2 libname A4Q2 °D: n Temp°; (a) data familyt(keep=famid year income expense debit); set a4q2.family; array inclist(*) inc90-inc99; array explist(*) exp90-exp99; array deblist(*) deb90-deb99; do j=1 to 10; year = 1989+j; income = inclist(j); expense = explist(j); debit = deblist(j); if income~=. or expense~=.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern