01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive Medicine, University of Ottawa
SAS Output Delivery System (ODS) Default method for getting output from SAS procedures Can produce: –printed results –graphics (hi-res) –Data tables for use in future procs 01/20152
SAS Output Delivery System (ODS) Output formats include: –HTML –RTF –PDF Provides extensive control of output format, colors, etc. –1500 page ‘basic manual’. –more manuals for graphics 01/20153
SAS Output Delivery System (ODS) Basic use is relatively simple –80/20 rule –add on features as you get better at it By default, ALL SAS output is prepared as HTML –Presented in the Results Window 01/20154
5 ODS produces output which has two components
01/20156 To change type of output: ODS HTML close; ODS PDF; To save output to a file: ODS HTML file = ‘file_name.html’; -Can define the filename in a ‘filename’ statement and put the reference here: filename f1 ‘C:/home/EPI5344.html’; ODS HTML file=f1;
01/20157 To change the style of output: ODS HTML style=beige; When ready to actually save your output file, place this statement at the end of your code: ODS HTML close; Place an ‘ODS HTML’ at the start of your file to re-open output stream.
ODS pdf style=Normal 01/20158 ODS pdf style=Torn ODS pdf style=Journal
01/20159 HTML Output
01/ RTF Output - displayed in Word
01/ PDF Output
01/ Graphics example
01/ Graphics example
Some ODS code ODS HTML file ‘C:/mysas.html’; ods pdf file=‘C:/mysas.pdf’; ods rtf file=‘C:/mysas.rtf’; ods ps file=‘C:/mysas.ps’; proc print data=employee_data (obs=12); id idnumber; title ‘Personnel data’; run; ods _all_ close; ods listing; 01/201514
2 other ODS commands Get a list of the tables created by a Proc. Use to link data into subsequent Procs. Result is placed in ‘LOG FILE’. ODS trace on; proc freq data=t1; run; ODS trace off; 01/201515
2280 ods trace on; 2281 proc lifetest data=njb1; 2282 time ftime*vstatus(0); 2283 run; Output Added: Name: ProductLimitEstimates Label: Product-Limit Estimates Template: Stat.Lifetest.ProductLimitEstimates Path: Lifetest.Stratum1.ProductLimitEstimates Output Added: Name: Quartiles Label: Quartiles of the Survival Distribution Template: Stat.Lifetest.Quartiles Path: Lifetest.Stratum1.TimeSummary.Quartiles /201516
Output Added: Name: Means Label: Mean Template: Stat.Lifetest.Means Path: Lifetest.Stratum1.TimeSummary.Means Output Added: Name: SurvivalPlot Label: Survival Curve Template: Stat.Lifetest.Graphics.ProductLimitSurvival Path: Lifetest.Stratum1.SurvivalPlot Output Added: Name: CensoredSummary Label: Censored Summary Template: Stat.Lifetest.CensoredSummary Path: Lifetest.CensoredSummary /201517
2 other ODS commands Produce graphical output. Output varies depending the Proc. ODS GRAPHICS ON; PROC LIFETEST DATA=allison.myel PLOTS=S; TIME dur*status(0); RUN; ODS GRAPHICS OFF; 01/201518
01/ Data for the Myelomatous data set, Allison
01/ DATA myel; INPUT dur status treat renal; DATALINES; ; run; SAS programme to read the Data for the Myelomatous data set, Allison
01/ PROC LIFETEST DATA=myel; TIME dur*status(0); RUN; Proc Lifetest ; Some Important Options DATA = SAS-data-set OUTSURV = data set containing survival estimates METHOD = KM/PL (Kaplan-Meier); LIFE (actuarial) PLOTS = S (survival); LS (log-survival); LLS (log-log survival); H (hazard)
01/201522
01/201523
01/ libname allison 'C:/allison_2010/data_sets'; ODS GRAPHICS ON; ODS HTML style=statistical; PROC LIFETEST DATA=allison.myel PLOTS=S; TIME dur*status(0); RUN; ODS HTML close; ODS GRAPHICS OFF;
Aside re: ‘plots’ To get more than one plot, place the request in brackets: proc lifetest data=allison.myel plots=(s,h,lls) 01/201525
01/201526
01/ libname allison 'C:/allison_2010/data_sets'; ODS GRAPHICS ON; ODS HTML style=statistical; PROC LIFETEST DATA=allison.myel PLOTS=S(NOCENSOR ATRISK CL); TIME dur*status(0); RUN; ODS HTML close; ODS GRAPHICS OFF;
01/201528
01/ libname allison 'C:/allison_2010/data_sets'; ODS GRAPHICS ON; ODS HTML style=statistical; PROC LIFETEST DATA=allison.myel PLOTS=S(NOCENSOR ATRISK CL CB=EP); TIME dur*status(0); RUN; ODS HTML close; ODS GRAPHICS OFF;
01/201530
01/ libname allison 'C:/allison_2010/data_sets'; PROC LIFETEST DATA=allison.myel OUTSURV=a; TIME dur*status(0); RUN; Proc Print data=a; Run;
01/201532
01/ libname allison 'C:/allison_2010/data_sets'; ODS OUTPUT ProductLimitEstimates=a; PROC LIFETEST DATA=allison.myel; TIME dur*status(0); RUN; Proc Print data=a; Run;
01/201534
Reading data from a text file into SAS 01/201535
01/ Sample Data (as given in file to be read)
01/ Sample Data (showing columns) Formats for data Col 1, F2.0 Col 4, F2.0 Col 7, F1.0
01/ Code to read in data. filename in ‘C:\data\sample1.txt’; data njb1; infile in; ID survtime status 1. ; run; proc print data=njb1 (obs=20); run;
01/201539