*** SAS file generated by sastangle ***; options nocenter nodate nonumber ls=80 formdlim=''; *** Code chunk number 1 ***; libname k "c:/book"; data help; set k.help; run; *** Code chunk number 3 ***; ods select modelinfo; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 4 ***; ods select nobs; ods noproctitle; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 5 ***; ods noproctitle; ods select responseprofile; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 6 ***; ods noproctitle; ods select classlevelinfo; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 7 ***; ods noproctitle; ods select convergencestatus; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 8 ***; ods noproctitle; ods select fitstatistics; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 9 ***; ods noproctitle; ods select globaltests; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 10 ***; ods noproctitle; ods select type3; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 11 ***; options ls=74; /* keep output in grey box */ ods noproctitle; ods select parameterestimates; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 12 ***; ods noproctitle; ods select oddsratios; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; *** Code chunk number 13 ***; ods noproctitle; ods select association; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; ods proctitle; *** Code chunk number 15 ***; ods exclude all; ods output parameterestimates=helplogisticbetas; proc logistic data=help descending; class substance (param=ref ref='alcohol'); model homeless = female i1 substance sexrisk indtot; run; ods exclude none; options ls=74; proc print data=helplogisticbetas; run; *** Code chunk number 16 ***; /* This code removes CI from ALL FOLLOWING proc genmod "parameterestimates" output. */ proc template; define table Stat.Genmod.ParameterEstimates; notes "Parameter estimates table."; dynamic PrtTitle1 PrtTitle2 PrtTitle3 PrtHead1 PrtHead2 alpha spansW spaneW spansLR spaneLR; column Parameter Level DF Estimate StdErr /*LowerWaldCL UpperWaldCL */ LowerLRCL UpperLRCL ChiSq ProbChiSq; header stitle1 stitle2 stitle3 header1 header2; define Parameter; header = "Parameter"; label = "Parameter"; style = RowHeader; id; end; define Level; print_headers = OFF; id; generic; end; define DF; parent = common.ParameterEstimates.DF; end; define Estimate; format = 8.4; parent = Common.ParameterEstimates.Estimate; end; define StdErr; format = 8.4; parent = Common.ParameterEstimates.StdErr; end; define LowerLRCL; format = 8.4; glue = 2; print_headers = OFF; end; define UpperLRCL; format = 8.4; print_headers = OFF; end; define ChiSq; header = "Wald Chi-Square"; translate _val_=._ into ""; format = 7.2; parent = Common.ANOVA.ChiSq; end; define ProbChiSq; translate _val_=._ into ""; parent = Common.ProbChiSq; end; define stitle1; text "Analysis Of Maximum Likelihood Parameter Estimates"; space = 1; print = PrtTitle1; end; define stitle2; text "Analysis Of Initial Parameter Estimates"; space = 1; print = PrtTitle2; end; define stitle3; text "Analysis Of Maximum Likelihood Zero Inflation Parameter Estimates "; space = 1; print = PrtTitle3; end; define header1; text "Wald " alpha %nrstr("%% Confidence Limits"); end = spaneW; start = spansW; print = PrtHead1; generic; end; define header2; text "Likelihood Ratio " alpha %nrstr("%% Confidence Limits"); end = spaneLR; start = spansLR; print = PrtHead2; generic; end; end; run; *** Code chunk number 18 ***; ods select modelfit; proc genmod data=help; class substance; model i1 = female substance age / dist=poisson; run; *** Code chunk number 19 ***; options ls=74; ods noproctitle; ods select parameterestimates; proc genmod data=help; class substance; model i1 = female substance age / dist=poisson; run; ods proctitle; *** Code chunk number 21 ***; options ls=74; ods select parameterestimates; proc genmod data=help; class substance; model i1 = female substance age / dist=zip; zeromodel female; run; *** Code chunk number 22 ***; ods noproctitle; ods select zeroparameterestimates; proc genmod data=help; class substance; model i1 = female substance age / dist=zip; zeromodel female; run; ods proctitle; *** Code chunk number 24 ***; ods proctitle; ods select modelfit; proc genmod data=help; class substance; model i1 = female substance age / dist=negbin; run; *** Code chunk number 25 ***; options ls=74; ods noproctitle; ods select parameterestimates; proc genmod data=help; class substance; model i1 = female substance age / dist=negbin; run; ods proctitle; *** Code chunk number 26 ***; ods select parameterestimates; proc quantreg data=help; class substance; model i1 = female substance age / quantile=0.75; run; *** Code chunk number 27 ***; data help3; set help; sexriskcat = (sexrisk ge 2) + (sexrisk ge 6); run; *** Code chunk number 28 ***; ods select parameterestimates; proc logistic data=help3 descending; model sexriskcat = cesd pcs; run; *** Code chunk number 30 ***; options ls=74; /* keep output in grey box */ ods proctitle; ods select responseprofile; proc logistic data=help3 descending; model sexriskcat = cesd pcs / link=glogit; run; *** Code chunk number 31 ***; options ls=74; /* keep output in grey box */ ods noproctitle; ods select parameterestimates; proc logistic data=help3 descending; model sexriskcat = cesd pcs / link=glogit; run; ods proctitle; *** Code chunk number 32 ***; ods select parameterestimates anodev smoothingcomponentplot; proc gam data=help plots=components(clm); class substance; model cesd = param(female) loess(pcs) param(substance) / method=gcv; run; *** Code chunk number 33 ***; /* Code below fixes apparent SAS bug with figure title */ proc template; define style Styles.Custom; parent = Styles.Printer; replace fonts / 'TitleFont' = ("Times Roman",0pt,Bold Italic) /* Titles from TITLE statements */ 'TitleFont2' = ("Times Roman",0pt,Bold Italic) /* Proc titles ("The ZZZ Procedure")*/ 'StrongFont' = ("Times Roman",0pt,Bold) ; end; run; ods pdf style = Custom; ods noproctitle; ods select smoothingcomponentplot; proc gam data=help plots=components(clm additive); class substance; model cesd = param(female) loess(pcs) param(substance) / method=gcv; run; ods proctitle; *** Code chunk number 34 ***; data long; set help; array cesd_a [4] cesd1 - cesd4; array mcs_a [4] mcs1 - mcs4; array i1_a [4] i11 - i14; array g1b_a [4] g1b1 - g1b4; do time = 1 to 4; cesdtv = cesd_a[time]; mcstv = mcs_a[time]; i1tv = i1_a[time]; g1btv = g1b_a[time]; output; end; run; *** Code chunk number 35 ***; proc freq data=long; tables g1btv*time / nocum norow nopercent; run; *** Code chunk number 36 ***; proc print data=long; where id eq 1; var id time cesd cesdtv; run; *** Code chunk number 37 ***; proc transpose data=long out=wide1 prefix=time; by notsorted id; var cesdtv mcstv i1tv g1btv; id time; run; *** Code chunk number 38 ***; proc print data=wide1 (obs=6); run; *** Code chunk number 39 ***; data wide (drop=_name_); merge wide1 (where = (_name_="cesdtv") rename = (time1=cesd1 time2=cesd2 time3=cesd3 time4=cesd4)) wide1 (where = (_name_="mcstv") rename = (time1=mcs1 time2=mcs2 time3=mcs3 time4=mcs4)) wide1 (where = (_name_="i1tv") rename = (time1=i11 time2=i12 time3=i13 time4=i14)) wide1 (where = (_name_="g1btv") rename = (time1=g1b1 time2=g1b2 time3=g1b3 time4=g1b4)); run; *** Code chunk number 40 ***; proc print data=wide (obs=2); var id cesd1 - cesd4; run; *** Code chunk number 41 ***; *** Code chunk number 42 ***; ods proctitle; ods select rcorr; proc mixed data=long; class time; model cesdtv = treat time / solution; repeated time / subject=id type=un rcorr=7; run; *** Code chunk number 43 ***; ods noproctitle; ods select covparms; proc mixed data=long; class time; model cesdtv = treat time / solution; repeated time / subject=id type=un rcorr=7; run; *** Code chunk number 44 ***; ods noproctitle; ods select solutionf; proc mixed data=long; class time; model cesdtv = treat time / solution; repeated time / subject=id type=un rcorr=7; run; *** Code chunk number 45 ***; ods noproctitle; ods select tests3; proc mixed data=long; class time; model cesdtv = treat time / solution; repeated time / subject=id type=un rcorr=7; run; ods proctitle; *** Code chunk number 46 ***; proc sgpanel data=long; panelby time / columns=4; vbox cesdtv / category=treat; run; *** Code chunk number 47 ***; data long2; set long; timecopy=time; run; *** Code chunk number 49 ***; proc sort data= long2; by id descending time; run; ods proctitle; ods select vcorr; ods output solutionr=reffs; proc mixed data=long2 order=data; class timecopy; model cesdtv = treat timecopy / solution; random int time / subject=id type=un vcorr=20; run; *** Code chunk number 50 ***; ods select covparms; ods output solutionr=reffs; proc mixed data=long2 order=data; class timecopy; model cesdtv = treat timecopy / solution; random int time / subject=id type=un vcorr=20; run; *** Code chunk number 51 ***; options ls=74; ods select solutionf; ods output solutionr=reffs; proc mixed data=long2 order=data; class timecopy; model cesdtv = treat timecopy / solution; random int time / subject=id type=un vcorr=20; run; *** Code chunk number 52 ***; ods select tests3; ods output solutionr=reffs; proc mixed data=long2 order=data; class timecopy; model cesdtv = treat timecopy / solution; random int time / subject=id type=un vcorr=20 solution; run; ods select all; *** Code chunk number 54 ***; options ls=74; proc print data=reffs; where strip(subject) eq '1'; run; *** Code chunk number 55 ***; ods exclude all; proc mixed data=long2 order=data; class timecopy; model cesdtv = treat timecopy / outp=lmmp outpm=lmmpm; random int time / subject=id type=un; run; ods select all; *** Code chunk number 56 ***; data lmmout; merge lmmp lmmpm (rename = (pred=margpred)); by id descending time; run; proc print data=lmmout; where id eq 1; var id time cesdtv pred margpred; run; *** Code chunk number 59 ***; ods proctitle; ods select geeemppest; proc genmod data=long2 descending; class id; model g1btv = treat time / dist=bin; repeated subject = id / type=exch corrw; run; *** Code chunk number 60 ***; ods noproctitle; ods select geewcorr; proc genmod data=long2 descending; class id; model g1btv = treat time / dist=bin; repeated subject = id / type=exch corrw; run; ods proctitle; *** Code chunk number 61 ***; ods select parameterestimates; proc glimmix data=long; model g1btv = treat cesdtv time / dist=bin solution; random int / subject=id; run; *** Code chunk number 62 ***; ods select parameterestimates; proc glimmix data=long method=laplace; model g1btv = treat cesdtv time / dist=bin solution; random int / subject=id; run; *** Code chunk number 64 ***; ods select censoredsummary; proc phreg data=help; class treat female; model dayslink*linkstatus(0) = treat age female cesd; run; *** Code chunk number 65 ***; ods noproctitle; ods select fitstatistics; proc phreg data=help; class treat female; model dayslink*linkstatus(0) = treat age female cesd; run; *** Code chunk number 66 ***; ods noproctitle; ods select globaltests; proc phreg data=help; class treat female; model dayslink*linkstatus(0) = treat age female cesd; run; *** Code chunk number 67 ***; /* This code suppresses the "label" column in proc phreg "parameterestimates" output. */ proc template; define table Stat.Phreg.ParameterEstimates; notes "Parameter Estimates Table"; dynamic Confidence NRows; column Parameter GenericClassValue DF Estimate StdErr StdErrRatio ChiSq ProbChiSq HazardRatio HRLowerCL HRUpperCL HRLowerPLCL HRUpperPLCL ; header h1 h2 h3; define h1; text "Analysis of Maximum Likelihood Estimates"; space = 1; spill_margin; end; define h2; text Confidence BEST8. %nrstr("%% Hazard Ratio Confidence Limits"); space = 0; end = HRUpperCL; start = HRLowerCL; spill_margin = OFF; end; define h3; text Confidence BEST8. %nrstr("%% Hazard Ratio Profile Likelihood Confidence Limits"); space = 0; end = HRUpperPLCL; start = HRLowerPLCL; spill_margin = OFF; end; define Parameter; header = "Parameter"; style = RowHeader; id; end; define GenericClassValue; header = " "; pre_space = 1; style = RowHeader; id; generic; end; define DF; parent = Common.ParameterEstimates.DF; end; define Estimate; header = ";Parameter;Estimate;"; format = D10.; parent = Common.ParameterEstimates.Estimate; end; define StdErr; header = ";Standard;Error;"; format = D10.; parent = Common.ParameterEstimates.StdErr; end; define StdErrRatio; header = ";StdErr;Ratio;"; format = 6.3; end; define ChiSq; parent = Stat.Phreg.ChiSq; end; define ProbChiSq; parent = Stat.Phreg.ProbChiSq; end; define HazardRatio; header = ";Hazard;Ratio;"; glue = 2; format = 8.3; end; define HRLowerCL; glue = 2; format = 8.3; print_headers = OFF; end; define HRUpperCL; format = 8.3; print_headers = OFF; end; define HRLowerPLCL; glue = 2; format = 8.3; print_headers = OFF; end; define HRUpperPLCL; format = 8.3; print_headers = OFF; end; /* define Label; header = "Label"; end; */ col_space_max = 4; col_space_min = 1; required_space = NRows; end; run; *** Code chunk number 68 ***; options ls=74; ods noproctitle; ods select parameterestimates; proc phreg data=help; class treat female; model dayslink*linkstatus(0) = treat age female cesd; run; ods proctitle; *** Code chunk number 69 ***; ods select cronbachalpha; proc corr data=help alpha nomiss; var f1a -- f1t; run; ods exclude none; *** Code chunk number 70 ***; ods select orthrotfactpat factor.rotatedsolution.finalcommunwgt; proc factor data=help nfactors=3 method=ml rotate=varimax; var f1a--f1t; run; *** Code chunk number 71 ***; ods select lineardiscfunc classifiedresub errorresub; proc discrim data=help out=ldaout; class homeless; var age cesd mcs pcs; run; *** Code chunk number 72 ***; axis1 label=("Prob(homeless eq 1)"); ods select "Histogram 1"; proc univariate data=ldaout; class homeless; var _1; histogram _1 / nmidpoints=20 haxis=axis1; run; *** Code chunk number 73 ***; ods exclude all; proc varclus data=help outtree=treedisp centroid; var mcs pcs cesd i1 sexrisk; run; ods exclude none; proc tree data=treedisp nclusters=5; height _varexp_; run;