%let location=C:\Documents and Settings\woodph\My Documents\glmwood\kutnersolutions\Chapter9; %include "&location\scatter.sas"; PROC IMPORT OUT= WORK.SurgUnit DATAFILE= "&location\Chapter9.xls" DBMS=EXCEL REPLACE; SHEET="CH09TA01$"; GETNAMES=YES; MIXED=NO; SCANTEXT=YES; USEDATE=YES; SCANTIME=YES; RUN; proc means; title "Summary Statistics. Refer to Table 9.1, p. 350";run; proc univariate freq plot;var _numeric_; histogram _numeric_/normal; title "Univariate Distributions";run; proc corr; title "Correlation Matrix Refer to paragraph 2, page 351 & values on page 352";run; proc reg; model Survival=Clotting Prognos Enzyme Liver Age Sex AlcMod AlcHeav/stb; plot residual.*predicted. residual.*nqq.; title "Initial model. Refer to Figure 9.2 figures a & b, p. 351";run; proc reg; model LnSurviv=Clotting Prognos Enzyme Liver Age Sex AlcMod AlcHeav/stb; plot residual.*predicted. residual.*nqq.; title "Log Survival model. Refer to Figure 9.2 figures c & d, p. 351"; title2 "(Note that the figure in (d) is incorrect- there is only one residual greater than .4 in the data)";run; %scatter(data = SurgUnit, var = LnSurviv Clotting Prognos Enzyme Liver); title "Scatterplot Matrix. Refer to Figure 9.3 Page 352";run; /*To get the press statistic, we are "stuck" making the observation-level variable, squaring it per formula 9.17 page 360 and summing it. e.g.:*/ proc reg; model LnSurviv=Clotting Prognos Enzyme Liver/stb selection=rsquare sse rsquare adjrsq cp aic sbc press jp pc sp gmsep; plot sse.*np. rsq.*np. adjrsq.*np. cp.*np. aic.*np. sbc.*np. sp.*np./chocking=red cmallows=green haxis=1 2 3 4; output out=resids press=pressval; title "Model Selection Criteria. See Figure 9.4, p. 356";run; proc print data=resids;run; data resids;set resids; pressval=pressval*pressval; proc means sum;var pressval; title "reference last line, table 9.2, page 353"; run; proc reg; model LnSurviv=Clotting Prognos Enzyme Liver/selection=maxr; title "MaxR stepwise, reference page 361";run; proc reg; model LnSurviv=Clotting Prognos Enzyme Liver/selection=forward; title "Forward stepwise, reference page 361";run; proc reg; model LnSurviv=Clotting Prognos Enzyme Liver/selection=backward; title "Backward stepwise, reference page 361";run; proc reg; model LnSurviv=Clotting Prognos Enzyme Liver/selection=minr; title "MinR stepwise, reference page 361";run;