BookmarkSubscribeRSS Feed
Calcite | Level 5

Hi all,

I am currently using Cox to estimate the hazard ratio of death in control vs treatment groups. However, there is an interaction with follow-up time and hazard ratio, with the HR initally being higher and crossing '1' after approx. 2 years of follow-up. I would like to visualize this changing HR by plotting the HR as a function of time. Is this possible in SAS?

Second question, am i correct in saying that the proportional hazards assumption is violated?

I have attached an example of what I am trying to achieve (attached PDF, figure 1B).

Thank you in advance for your help!

Kind regards,


Calcite | Level 5


Don't know if this topic still interests you.  I have a macro suite that implements Paul Lambert's flexible parametric survival analysis (stata) program stpm2.  With that installed, you will be able to fit a parametric model that allows for the HR to vary over follow-up time, and to plot the HR estimates (and its conf. limits).  It could also be used to estimate most of the other measures that you saw in the article you posted (hazard differences, differences in survival curves...)


Let me know if you are interested.


@epiman46 This sounds like a useful macro that would be nice to have.  Would you consider writing an article in the Library here on the SAS Support Communities?  You could post the macro to that article as a ZIP file. 


If the macro uses SAS/IML to do the computations, you could also post the macro to the SAS/IML File Exchange.

Calcite | Level 5


I certainly could.  The thing itself is still being developed, however, with some new features being added, now that I have a bit of time to work on it.  So I would want it to be clear that it is a work in progress, with some features fully realised, and others to come.  Currently, it clocks in at just over 1,700 lines of code.  But it would be really nice to get some feedback from users.


Is there an FAQ about writing for the library?



You can follow the basic advice in the article "How to contribute to the SAS/IML File Exchange." Most of the suggestions would apply equally well to a macro submission to the general library here at the SAS Support Communities.

Calcite | Level 5

I don't see this question has been answered. 

In SAS, is there a way to draw the hazard ratio over time plot? The y-axis is the hazard ratio and x-axis is time. The hazard ratio over time plot will be very useful when there is non-proportional-hazards situation. An example is the figure 1B in a paper by Uno et al "Moving Beyond the Hazard Ratio in Quantifying the
Between-Group Difference in Survival Analysis"




Calcite | Level 5

The methods I use fit a flexible parametric survival model that uses restricted cubic splines to model the underlying log cumulative survival function.  Interactions between a covariate and followup time can be easily accommodated. Many functions can be predicted using the model estimates, including hazard, hazard differences, survival differences and hazard ratios as functions of followup time.  This is all done in a suite of sas macros that implement much of what is available in Stata's user-written stpm2 module, and has been developed as a work-alike version of that module and its prediction functions.  I haven't published this suite yet, but am certainly willing to share it with you


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 5 in conversation