+ All Categories
Home > Documents > 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N....

01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N....

Date post: 02-Jan-2016
Category:
Upload: hannah-mcbride
View: 221 times
Download: 1 times
Share this document with a friend
39
01/2015 1 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
Transcript
Page 1: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 1

EPI 5344:Survival Analysis in

EpidemiologySAS code and output

February 24, 2015

Dr. N. Birkett,School of Epidemiology, Public Health &

Preventive Medicine,University of Ottawa

Page 2: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

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/2015 2

Page 3: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

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 graphics01/2015 3

Page 4: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

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/2015 4

Page 5: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 5

ODS produces output which has two components

Page 6: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 6

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;

Page 7: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 7

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.

Page 8: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

ODS pdf style=Normal

01/2015 8

ODS pdf style=Torn

ODS pdf style=Journal

Page 9: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 9

HTML Output

Page 10: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 10

RTF Output- displayed in Word

Page 11: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 11

PDF Output

Page 12: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 12

Graphicsexample

Page 13: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 13

Graphicsexample

Page 14: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

Some ODS code

ODS HTMLfile ‘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/2015 14

Page 15: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

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/2015 15

Page 16: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

2280 ods trace on;2281 proc lifetest data=njb1;2282 time ftime*vstatus(0);2283 run;

Output Added:-------------Name: ProductLimitEstimatesLabel: Product-Limit EstimatesTemplate: Stat.Lifetest.ProductLimitEstimatesPath: Lifetest.Stratum1.ProductLimitEstimates-------------

Output Added:-------------Name: QuartilesLabel: Quartiles of the Survival DistributionTemplate: Stat.Lifetest.QuartilesPath: Lifetest.Stratum1.TimeSummary.Quartiles-------------01/2015 16

Page 17: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

Output Added:-------------Name: MeansLabel: MeanTemplate: Stat.Lifetest.MeansPath: Lifetest.Stratum1.TimeSummary.Means-------------

Output Added:-------------Name: SurvivalPlotLabel: Survival CurveTemplate: Stat.Lifetest.Graphics.ProductLimitSurvivalPath: Lifetest.Stratum1.SurvivalPlot-------------

Output Added:-------------Name: CensoredSummaryLabel: Censored SummaryTemplate: Stat.Lifetest.CensoredSummaryPath: Lifetest.CensoredSummary-------------01/2015 17

Page 18: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

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/2015 18

Page 19: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 19

8 1 1 1 180 1 2 0 632 1 2 0 852 0 1 0 52 1 1 12240 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 11990 0 2 01976 0 1 0 18 1 2 1 700 1 2 01296 0 1 01460 0 1 0 210 1 2 0 63 1 1 11328 0 1 01296 1 2 0 365 0 1 0 23 1 2 1

Data for the Myelomatous data set, Allison

Page 20: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 20

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 12240 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 11990 0 2 01976 0 1 0 18 1 2 1 700 1 2 01296 0 1 01460 0 1 0 210 1 2 0 63 1 1 11328 0 1 01296 1 2 0 365 0 1 0 23 1 2 1;run;

SAS programme to read the Data for the Myelomatous data set, Allison

Page 21: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 21

PROC LIFETEST DATA=myel;

TIME dur*status(0);

RUN;

Proc Lifetest <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)

Page 22: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 22

Page 23: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 23

Page 24: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 24

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;

Page 25: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

Aside re: ‘plots’

• To get more than one plot, place the request in brackets:

proc lifetest data=allison.myel plots=(s,h,lls)

01/2015 25

Page 26: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 26

Page 27: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 27

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;

Page 28: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 28

Page 29: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 29

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;

Page 30: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 30

Page 31: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 31

libname allison 'C:/allison_2010/data_sets';

PROC LIFETEST DATA=allison.myel OUTSURV=a; TIME dur*status(0);RUN;

Proc Print data=a;Run;

Page 32: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 32

Page 33: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 33

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;

Page 34: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 34

Obs STRATUM dur Censor Survival Failure StdErr Failed Left

1 1 0.00 . 1.0000 0 0 0 25

2 1 8.00 0 . . . 1 24

3 1 8.00 0 0.9200 0.0800 0.0543 2 23

4 1 13.00 0 0.8800 0.1200 0.0650 3 22

5 1 18.00 0 0.8400 0.1600 0.0733 4 21

6 1 23.00 0 0.8000 0.2000 0.0800 5 20

7 1 52.00 0 0.7600 0.2400 0.0854 6 19

8 1 63.00 0 . . . 7 18

9 1 63.00 0 0.6800 0.3200 0.0933 8 17

10 1 70.00 0 0.6400 0.3600 0.0960 9 16

Page 35: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

• Reading data from a text file into SAS

01/2015 35

Page 36: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 36

Sample Data (as given in file to be read)

1 56 0

2 7 1

3 21 0

4 62 0

5 38 0

Page 37: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 37

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

Page 38: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 38

Code to read in data.

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;

Page 39: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS code and output February 24, 2015 Dr. N. Birkett, School of Epidemiology, Public Health & Preventive.

01/2015 39


Recommended