options pagesize=47 linesize=64; data larynx; infile 'larynx.dat'; input stage time age year status; year=year-74; stg1=0; stg2=0; stg3=0; stg4=0; if stage=1 then stg1=1; if stage=2 then stg2=1; if stage=3 then stg3=1; if stage=4 then stg4=1; as1=age*stg1; as2=age*stg2; as3=age*stg3; as4=age*stg4; run; data stages23; set larynx; if stage <2 | stage>3 then delete; run; title1 'Larynx Cancer Survival Stage 2 and 3'; title2 'Testing Stage, using STRATA command'; /***********************************************************/ /* We will repeat some calculations we did earlier for */ /* comparison purposes. Log rank statistic corresponds to */ /* score statistic for regression model. */ /***********************************************************/ proc lifetest data=stages23 notable; time time*status(0) ; strata stage; run; title2 'Testing Stage, using TEST command'; proc lifetest data=stages23 notable; time time*status(0) ; test stage; run; /***********************************************************/ /* Fit proportional hazards model. discrete tie handling */ /* below corresponds to exact in R. */ /***********************************************************/ proc phreg data=stages23; title2 'Tie handling same as for strata with LIFETEST'; model time*status(0)=stg3/ ties=discrete; run; /* Option breslow below is default in SAS*/ proc phreg data=stages23; title2 'Tie handling same as for test with LIFETEST'; model time*status(0)=stg3/ ties=breslow; run; title2 ''; proc phreg data=stages23; title2 'Ties handled using Efron method'; model time*status(0)=stg3/ ties=efron; run; title1 'Larynx Cancer All Stages: ANOVA--Like Analysis'; proc phreg data=larynx; model time*status(0)=stg2 stg3 stg4; run; proc phreg data=larynx; title2 'Age added as covariate'; model time*status(0)=stg2 stg3 stg4 age; run; proc phreg data=larynx; titlel 'Using stage as quant. instead of categorical'; model time*status(0)=age year stage; run; /***********************************************************/ /* Some SAS procedures allow you to use a categorical vari-*/ /* able like stage as above by adding a class statement. */ /* You can't do this with proc phreg. */ /***********************************************************/ proc phreg data=larynx; title1 'An alternate parameterization of stage'; model time*status(0)=stg1 stg2 stg3; run; /***********************************************************/ /* Some SAS procedures allow you to specify interaction */ /* terms as a multiplication on the model statement. You */ /* can't do this with proc phreg. */ /***********************************************************/ proc phreg data=larynx; title1 'Correct way to use interactions'; model time*status(0)=age year stg2 stg3 stg4 as2 as3 as4 ; run;