options formdlim="-" nodate ls=95; data heights; infile "heightdat.txt" firstobs=5; /* FIRSTOBS=5 ignores 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; proc means data=heights mean n std stderr css; title "xbar and ybar"; var x y; run; proc corr cov; var x y; run; /* run all the code prior to this comment to generate necessary output for homework problem #2 */ ods listing close; /* this stops sending output to the output window */ 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 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;