*** Some Examples of SAS Program for Cox Proportional Hazards Model *** These were selected programs and data sets from the book, "Survival Analysis Using the SAS System: A Practical Guide" by Paul D. Allison. SAS Publications order # 55233 ISBN 1-55544-279-X Copyright 1995 by SAS Institute Inc., Cary, NC, USA /********************************************************/ /*********************Simple Cox model ******************/ /********************************************************/ /* The following program is found on page 119 of the book. */ /* Fit a fixed covariate Cox model to transplant subjects. */ data stan; infile 'c: stan.dat'; input dob mmddyy9. doa mmddyy9. dot mmddyy9. dls mmddyy9. dead surg m1 m2 m3; surv1=dls-doa; surv2=dls-dot; ageaccpt=(doa-dob)/365.25; agetrans=(dot-dob)/365.25; wait=dot-doa; if dot=. then trans=0; else trans=1; run; proc phreg data=stan; where trans=1; model surv2*dead(0)=surg m1 m2 m3 agetrans wait dot; run; /********************************************************/ /*******************stratified Cox model ****************/ /********************************************************/ /* The following program is found on page 158 of the book. */ data myel; input id dur status treat renal; cards; 1 8 1 1 1 2 180 1 2 0 3 632 1 2 0 4 852 0 1 0 5 52 1 1 1 6 2240 0 2 0 7 220 1 1 0 8 63 1 1 1 9 195 1 2 0 10 76 1 2 0 11 70 1 2 0 12 8 1 1 0 13 13 1 2 1 14 1990 0 2 0 15 1976 0 1 0 16 18 1 2 1 17 700 1 2 0 18 1296 0 1 0 19 1460 0 1 0 20 210 1 2 0 21 63 1 1 1 22 1328 0 1 0 23 1296 1 2 0 24 365 0 1 0 25 23 1 2 1 ; proc phreg data=myel; model dur*status(0)=treat; strata renal; run; /********************************************************/ /*****************time dependent covariate***************/ /********************************************************/ /* The following program is found on page 139 of the book. */ /* It use one time dependent covariate of plant */ proc phreg data=stan; model surv1*dead(0)=plant surg ageaccpt / ties=exact; if wait>surv1 or wait=. then plant=0; else plant=1; run; /* The following program is found on page 156 of the book. */ /* One time dependent covariate: fin*week */ proc phreg data=recid; model week*arrest(0)=fin age race wexp mar paro prio fintime / ties=efron; fintime=fin*week; run; /* The following program is found on page 157 of the book. */ /* Again one time dependent corariate. */ proc phreg data=recid; model week*arrest(0)=fin age race wexp mar paro prio fintime / ties=efron; fintime=fin*(week>13); run; /****************************************************************/ /***********************fit baseline and predict*****************/ /****************************************************************/ /* The following program is found on page 165 of the book. */ /* Output the baseline survival etc. */ proc phreg data=recid; model week*arrest(0)=fin age prio / ties=efron; baseline out=a survival=s logsurv=ls loglogs=lls; run; proc print data=a; run; /* The following programs are found on page 171 of the book. */ proc phreg data=recid; model week*arrest(0)=fin finmid age prio / ties=efron; mid=(20