Hi,
I am using PROC PHREG to estimate the hazards ratio of death in a multivariable model with one continuous variable of particular interest. I would like to plot hazards ratio by this variable. This question has been asked here before, but it was not answered clearly. The problem does not lie in plotting the hazards ratio but rather in exporting this for each value of the variable of interest. I tried several statements in PROC PHREG and didn't come to my wish. Very simplified my model looks like this:
proc phreg data=mydata;
strata var1;
class var2 var3;
model Time*censor(0) = ContinousVar var2 var3;
run;
This is the plot I am trying to generate. As you can see I need the hazards ratio by different values of the variable of interest as well as the confidence interval.
I would appreciate any help.
Thanks
but once you have the model estimates you can just calculate the HR for any range of values of the continuous variable ie do it in a data step rather than exporting from phreg
edit, something like:
ods output parameterestimates=out (keep=estimate parameter where=(parameter="xxxxx"));
proc phreg data=xxxxx;
class aaa bbb ccc;
model surv*cens(1)= ...../ rl alpha=0.05;
run;
data .....;
set out;
do x=.... to .... by ....;
val=exp(estimate*x);
output;
end;
run;
??
but once you have the model estimates you can just calculate the HR for any range of values of the continuous variable ie do it in a data step rather than exporting from phreg
edit, something like:
ods output parameterestimates=out (keep=estimate parameter where=(parameter="xxxxx"));
proc phreg data=xxxxx;
class aaa bbb ccc;
model surv*cens(1)= ...../ rl alpha=0.05;
run;
data .....;
set out;
do x=.... to .... by ....;
val=exp(estimate*x);
output;
end;
run;
??
Thanks @pau13rown, but is this the way to do it when the relationship is non-linear as well?
i would think so, ie write the model out as it should be in the data step (with any nonlinear terms) and then see if the plot makes sense. Eg these authors found "a significant nonlinear relationship with regard to the composite of death/HF hospitalization (P = 0.0039), with a plateau of effect beyond 180 ms for the composite outcome" [https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3855551/] and this is seen in the plot: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3855551/figure/EHT290F3/?report=objectonly
it is a shame that authors don't routinely make programming code available on publication
@pau13rown wrote:it is a shame that authors don't routinely make programming code available on publication
I absolutely agree. I have asked here before for example analysis of clinical trials and prospective or retrospective studies. Unfortunately, not much was available. I would appreciate it if you have any that I can learn from.
Thanks for the answer.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.