* SAS LAb 4 Exercise solution; PROC IMPORT out=S3A3.BGSgirls datafile="BGSgirls.txt" DBMS=DLM REPLACE; Getnames=yes; Datarow=2; run; * The three scatterplots; * You could also use a single PROC PLOT but the plots are not as nice; PROC SGPLOT Data=S3A3.BGSgirls; Scatter X=HT2 Y=WT2; run; PROC SGPLOT Data=S3A3.BGSgirls; Scatter X=HT9 Y=WT9; run; PROC SGPLOT Data=S3A3.BGSgirls; Scatter X=HT18 Y=WT18; run; * The regressions and plots with fitted lines; PROC REG Data=S3A3.BGSgirls plots=none; Model WT2=HT2; Title "AGE 2"; Plot WT2*HT2; run; PROC REG Data=S3A3.BGSgirls plots=none; Model WT9=HT9; Title "AGE 9"; Plot WT9*HT9; run; PROC REG Data=S3A3.BGSgirls plots=none; Model WT18=HT18; Title "AGE 18"; Plot WT18*HT18; run; * Create the new variable; DATA S3A3.BGSgirls; Set S3A3.BGsgirls; BMI18 = WT18/(HT18/100)**2; run; * The scatterplot matrix; PROC SGSCATTER Data=S3A3.BGSgirls; Matrix BMI18 WT2 HT2 WT9 HT9; run; * The multiple regression for BMI at age 18 and fitted value plot; PROC REG Data=S3A3.BGSgirls plots=none; Model BMI18=WT2 HT2 WT9 HT9; Plot Pred.*BMI18; Title "Multiple Regression Model"; run; * Set up a new dataset with the additional values; Data BGSgirls_pred; Input WT2 HT2 WT9 HT9; Datalines; 12 82 25 125 14 84 30 135 15 86 35 135 15 90 40 140 16 93 45 140 ; Data BGSgirls_pred; Set BGSgirls_pred S3A3.BGSgirls; run; * Calculate and print out the predictions; PROC REG Data=BGSgirls_pred plots=none noprint; Model BMI18=WT2 HT2 WT9 HT9; Output Out=BGSgirls_pred(where=(BMI18=.)) Predicted=Pred LCLM=LowerCI UCLM=UpperCI LCL=LowerPI UCL=UpperPI; run; quit; PROC PRINT Data=BGSgirls_pred; run;