![Page 1: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/1.jpg)
101/2015
EPI 5344:Survival Analysis in
EpidemiologySAS Code for Cox models
March 17, 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 for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/2.jpg)
201/2015
SAS code (1)
• Cox models use Proc PHREG– I assume that you all have at least Version 9.2
of SAS• Prior to this version, ‘phreg’ was more limited• An experimental version (tphreg) could be used
instead. BUT, I strongly encourage you to upgrade to at least SAS 9.2
– Current version is 9.4
![Page 3: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/3.jpg)
301/2015
libname allison 'C:/allison_2010/data_sets';
PROC PHREG DATA=allison.recid; MODEL week*arrest(0)=fin age race wexp mar paro prio;RUN;
![Page 4: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/4.jpg)
401/2015
![Page 5: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/5.jpg)
501/2015
![Page 6: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/6.jpg)
601/2015
![Page 7: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/7.jpg)
701/2015
title 'Ties Handling: BRESLOW';PROC PHREG DATA=allison.recid; MODEL week*arrest(0)=fin age race wexp mar paro prio / TIES=BRESLOW;RUN;
title 'Ties Handling: EFRON';PROC PHREG DATA=allison.recid; MODEL week*arrest(0)=fin age race wexp mar paro prio / TIES=EFRON;RUN;
title 'Ties Handling: EXACT’;PROC PHREG DATA=allison.recid; MODEL week*arrest(0)=fin age race wexp mar paro prio / TIES=EXACT;RUN;
![Page 8: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/8.jpg)
801/2015
Breslow
Efron
Exact
![Page 9: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/9.jpg)
901/2015
Breslow
Efron
Exact
![Page 10: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/10.jpg)
1001/2015
Breslow
Efron &Exact
![Page 11: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/11.jpg)
1101/2015
PROC PHREG DATA=allison.recid; class fin /param=ref ref=last
; MODEL week*arrest(0)=fin age race wexp mar paro prio / TIES=EFRON;RUN;
PROC PHREG DATA=allison.recid; class fin /param=effect
; MODEL week*arrest(0)=fin age race wexp mar paro prio / TIES=EFRON;RUN;
![Page 12: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/12.jpg)
1201/2015
Reference coding
![Page 13: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/13.jpg)
13
An issue with ref coding (1)
• By default, SAS orders the levels of a categorical variable by the ‘format’ labels if they have been assigned.
• Consider:
01/2015
Category Format Order1 low 2
2 in-between 1
3 most 3
![Page 14: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/14.jpg)
14
An issue with ref coding (2)• You want to use ‘level=1’ as the reference.• This SAS code won’t do that: class x/param=ref ref=first;• Instead, the reference will be level 2.• You must use this code: class x/param=ref ref=first order=internal;
01/2015
![Page 15: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/15.jpg)
1501/2015
Effect coding
![Page 16: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/16.jpg)
16
Three-level class variable
• Just for test purposes, define a 3 level variable– combines race and financial aid:
01/2015
Race Financial aid Racefin0 0 1
0 1 1
1 0 2
1 1 3
![Page 17: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/17.jpg)
1701/2015
PROC PHREG DATA=njb1; class racefin /param=ref ref=last
; MODEL week*arrest(0)=racefin age / TIES=EFRON;RUN;
PROC PHREG DATA=njb1; class racefin /param=effect
; MODEL week*arrest(0)=racefin age / TIES=EFRON;RUN;
PROC PHREG DATA=njb1; class racefin /param=orthopoly
; MODEL week*arrest(0)=racefin age / TIES=EFRON;RUN;
![Page 18: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/18.jpg)
1801/2015
Reference coding
![Page 19: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/19.jpg)
1901/2015
Effect coding
![Page 20: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/20.jpg)
2001/2015
Ortho-polynomial coding
![Page 21: 01/20151 EPI 5344: Survival Analysis in Epidemiology SAS Code for Cox models March 17, 2015 Dr. N. Birkett, School of Epidemiology, Public Health Preventive](https://reader035.vdocument.in/reader035/viewer/2022062413/5a4d1b6b7f8b9ab0599b35dd/html5/thumbnails/21.jpg)
2101/2015