320 likes | 474 Views
EPI 5344: Survival Analysis in Epidemiology SAS code and output February 25, 2013. Dr. N. Birkett, Department of Epidemiology & Community Medicine, University of Ottawa. SAS Output Delivery System (ODS). Default method for getting output from SAS procedures Can produce: printed results
E N D
EPI 5344:Survival Analysis in EpidemiologySAS code and outputFebruary 25, 2013 Dr. N. Birkett, Department of Epidemiology & Community 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
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 • 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 • the Results Window
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; 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;
ODS pdf style=Normal ODS pdf style=Torn ODS pdf style=Journal
RTF Output - displayed in Word
Graphics example
Graphics example
2 other ODS commands Get a list of the tables created by a Proc. Use to link data into subsequent Procs; ODS trace on; procfreq data=t1; run; ODS trace off; 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;
8 1 1 1 180 1 2 0 632 1 2 0 852 0 1 0 52 1 1 1 2240 0 2 0 220 1 1 0 63 1 1 1 195 1 2 0 76 1 2 0 70 1 2 0 8 1 1 0 13 1 2 1 1990 0 2 0 1976 0 1 0 18 1 2 1 700 1 2 0 1296 0 1 0 1460 0 1 0 210 1 2 0 63 1 1 1 1328 0 1 0 1296 1 2 0 365 0 1 0 23 1 2 1 Data for the Myelomatous data set, Allison
DATA myel; INPUT dur status treat renal; DATALINES; 8 1 1 1 180 1 2 0 632 1 2 0 852 0 1 0 52 1 1 1 2240 0 2 0 220 1 1 0 63 1 1 1 195 1 2 0 76 1 2 0 70 1 2 0 8 1 1 0 13 1 2 1 1990 0 2 0 1976 0 1 0 18 1 2 1 700 1 2 0 1296 0 1 0 1460 0 1 0 210 1 2 0 63 1 1 1 1328 0 1 0 1296 1 2 0 365 0 1 0 23 1 2 1 ; run; SAS programme to read the Data for the Myelomatous data set, Allison
PROC LIFETEST DATA=myel; TIME dur*status(0); RUN; ProcLifetest <options>; 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)
libnameallison '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: proclifetest data=allison.myel plots=(s,h,lls)
libnameallison '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;
libnameallison '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;
libnameallison 'C:/allison_2010/data_sets'; PROC LIFETEST DATA=allison.myel OUTSURV=a; TIME dur*status(0); RUN; Proc Print data=a; Run;
Sample Data (as given in file to be read) 1 56 0 2 7 1 3 21 0 4 62 0 5 38 0
Sample Data (showing columns) 123456789012345 1 56 0 2 7 1 3 21 0 4 62 0 5 38 0 Formats for data • Col 1, F2.0 • Col 4, F2.0 • Col 7, F1.0
Code to read in data. options ps = 58; options ls = 78; filename in ‘C:\data\sample1.txt’; data njb1; infile in; input @1 ID 2. @4 survtime 2. @7 status 1. ; run; proc print data=njb1 (obs=20); run;