Programming the statistical procedures from SAS

Multivariable Cox assumption of proportional hazards

New Contributor
Posts: 4

Multivariable Cox assumption of proportional hazards

Hello everyone,


I am doing a Cox's model with delayed entry.



proc phreg data=food;
  class sexe_cl IPAQ1(ref="1") tabac_2classes;
model(age_inclus,age_fin)*censure(1)=ultraprocessed sexe_cl IMC taille nb_enq Alc kcal IPAQ1 diplome_3cl tabac_2classes atcd_K0
/ risklimits ties=efron;
run ;

age_inclus is the age at the inclusion of the participant.

age_fin is the age at the minimum between the date of censure or the date of death or the date of last follow-up.

ultraprocessed is my variable of interest.

The other variables are explicative.


I would like to draw the graph of Martingale or schoenfeld residuals to see if the variables follow the proportional hazards hypothesis and i don't know how to dot it. Do you have an idea please ?

Thanks in advance,

Best regards,




Super Contributor
Posts: 301

Re: Multivariable Cox assumption of proportional hazards

Posted in reply to Lostinstats

As I see it, it is not at present possible to make the assessment of the proportional hazard assumption with use of martingales in PROC PHREG when there is either lefttruncated timevalues or timedependent covariates in the model. It is also a big wish for me, so I hope it will come in a future release (Please, SAS Institute, we want that).


I worked some time ago with the same problem, and I was able to write both a cox-regression macro and a goodness-of-fit macro - see attachment. But it is difficult to use, and I have not made a very good documentation. It require that all covariates are specified as continous variables x_1-x_n, and they are lineary independent. (A class variable with three levels should be written as two variables). Also, it require a definition of some matrix functions which I also have attached. There is a libname statement where the path should be corrected to what ever drive you want to store these functions on. So, first declare the matrix-functions, then make your data with covariates x1-x_n, then estimate with the "%oldcox_regression" macro, then run the "%goodness_of_fit" macro" there is an example in the file, so you can try on that first.


I will recommend that you simplify your model, and put all covariates that is not of interest into the strata-statement, so there is less parameters to check for.


By the way, It is possible to make the assessment much faster (lineary time) than what phreg do (quadratic time).

New Contributor
Posts: 4

Re: Multivariable Cox assumption of proportional hazards

Posted in reply to JacobSimonsen
thank you for your detailed answer. I will try this, even if it seems to be difficult.
Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation