/* Computer Exercise #2 */ libname dataout 'c:\faiz\sas\sasdata\fall97\bios145'; options pageno=1 ps=56 ls=79; footnote 'SAS program: c:\faiz\sas\source\fall97\bios145\compex2.sas'; proc format; value sft 0="Female" 1="Male" ; run; data one; set dataout.pone; bmi = wt / ((ht/100)**2); ** Create BMI variable **; sex10 = sex-1; ** Create 0/1 variable for sex **; format sex10 sft.; run; proc sort data=one out=two; ** Sort data by SEX **; by sex10; run; /* #1: Using a regression model to get (unadjusted) differences in mean HDL between men and women (we need beta1hat) */ proc reg data=two; model hdl=sex10; title2 "#1: Using a regression model to get (unadjusted) differences"; title3 "in mean HDL between men and women"; quit; /* #2: Means of AGE and ALC by SEX */ proc means data=two mean; class sex10; var age alc; title2 "#2: Means of AGE and ALC by SEX"; run; /* #2: Correlation coefficients for HDL vs. AGE and HDL vs. ALC */ proc corr data=two; var hdl; with age alc; title2 "#2: Correlation coefficients for HDL vs. AGE and HDL vs. ALC"; quit; /* #3: Modelling HDL as a function of AGE, BMI, ALC, SEX, and the ALC*SEX interaction */ ** Testing the interaction -- need partial-F or t **; proc glm data=two; model hdl=age bmi alc sex10 alc*sex10; title2 "#3: Modelling HDL as a fn of AGE, BMI, ALC, SEX, and the ALC*SEX interaction"; title3 "Testing the interaction -- need partial-F or t"; quit; /* #5: Finding partial correlation coefficient */ proc glm data=two; where (sex10=0); model hdl=age bmi alc; title2 "#5: Finding partial correlation coefficient"; quit; /* #5: Finding partial correlation coefficient by PROC REG's PCORR2 option */ proc reg data=two; where (sex10=0); model hdl=age bmi alc / pcorr2; quit; /* #5: Finding unadjusted correlation coefficient */ proc corr data=two; where (sex10=0); var hdl; with alc; quit;