options formdlim="-" nodate ls=75; data heights; infile "heightdat.dat" firstobs=5; /* ignore first 4 lines of text in datafile*/ input x y; run; proc reg data=heights simple; model y=x; /* get PROC REG to do the work for us */ run; /* do the work ourselves, working through the nuts and bolts for problem #1, HW1 */ proc means data=heights mean n min max std stderr css; title "xbar and ybar"; var x y; run; ods listing close; /* this suppresses the output */ proc glm data=heights; /* this is a trick to compute x-xbar, y-ybar */ model x y=; output out=heights2 r=xdev ydev p=xbar ybar; run; /* compute those sums of squares and cross products for parts iii-ix */ data heights2; set heights2; xdev2=xdev**2; ydev2=ydev**2; xydev=xdev*ydev; run; ods listing ; /* this restarts the output */ proc means data=heights2 mean n min max sum css; title "sums of squares and cross-products"; var x y xdev ydev xdev2 ydev2 xydev; output out=heightsums mean=xbar ybar sum=junk1-junk4 ssx ssy sxy; run; proc print data=heightsums; title "summary statistics necessary to compute LS regression line"; run; data lsline; set heightsums; beta1hat=sxy/ssx; beta0hat=ybar-beta1hat*xbar; run; proc print data=lsline; title "LS line crunched out the hard way, agrees with PROC REG"; run;