********************************************************************* * Data taken from Exercise 10.8, p698 * * in Moore and McCabe, Intro to the Practice of Statistics, 3rd ed. * *********************************************************************; *The following linesize (ls) and pagesize (ps) options work well if you have your print setup (click file, print setup) with 0.5 in margins and portrait selected on page setup and and SAS Monospace, Roman, size 8 selected on font. The print setup display will tell you the ls and ps for the selections you have chosen. Some printers may be a little different and you may need to play with these settings; options ls=72 nocenter; goptions device=win target=winprtm rotate=landscape ftext=swiss hsize=8.0in vsize=6.0in htext=1.5 htitle=1.5 hpos=80 vpos=80 horigin=0.5in vorigin=0.5in ; *read in the data using the cards statement. The @@ allows more than one case per line. The . represents a missing value; data a1; input year lean @@; cards; 75 642 76 644 77 656 78 667 79 673 80 688 81 696 82 698 83 713 84 717 85 725 86 742 87 757 102 . ; *create new data set that does not include the last case; data a1p; set a1; if lean ne .; *print the data set a1; proc print data=a1; run; *generate a scatterplot with smooth curve fitted to the data; symbol1 v=circle i=sm70; proc gplot data=a1p; plot lean*year/frame; run; *perform regression analysis using data set a1. The clb option generates confidence interval for the slope and intercept. The p option generates fitted values and standard errors. The r option does some residual analysis (i.e., check assumptions). The output statement generates a new data set that contains the residuals and predicted/fitted values. The id statement adds the variable specified to the fitted values output; proc reg data=a1; model lean=year/clb p r; output out=a2 p=pred r=resid; id year; *generates a residual plot to assess model assumptions; proc gplot data=a2; plot resid*year/frame vref=0; where lean ne .; run;