BookmarkSubscribeRSS Feed
lei
Obsidian | Level 7 lei
Obsidian | Level 7

Hi,

 

I am running a cox-proportional hazards model. I want to get a predicted days out of this model. I am wondering if anyone can help. I know proc phreg has the output procedure but I don't see options. Can anyone help?

 

Thanks.

 

Shirley

 

4 REPLIES 4
Reeza
Super User

It may be terminology differences, but I don't think Proc Phreg does that, I think Proc Lifereg does.

 

Proc Phreg produces a survival function (or failure), so the probability of survival at various times. 

 

I'm also not sure what you mean by output procedure, what are you expecting to get out?

Rick_SAS
SAS Super FREQ

You can get the number of patients at risk for each day, which gives the numbers in the survival plot.  For example, the following program is copied from the Getting Started example in PROC PHREG. The ATRISK= option on the OUTPUT statement adds the at risk values to the OUT= data set.

 

data Rats;
   label Days  ='Days from Exposure to Death';
   input Days Status Group @@;
   datalines;
143 1 0   164 1 0   188 1 0   188 1 0
190 1 0   192 1 0   206 1 0   209 1 0
213 1 0   216 1 0   220 1 0   227 1 0
230 1 0   234 1 0   246 1 0   265 1 0
304 1 0   216 0 0   244 0 0   142 1 1
156 1 1   163 1 1   198 1 1   205 1 1
232 1 1   232 1 1   233 1 1   233 1 1
233 1 1   233 1 1   239 1 1   240 1 1
261 1 1   280 1 1   280 1 1   296 1 1
296 1 1   323 1 1   204 0 1   344 0 1
;

data Regimes;
   Group=0;   output;   Group=1;   output;
run;

ods graphics on;
proc phreg data=Rats plot(overlay)=survival;
   model Days*Status(0)=Group;
   baseline covariates=regimes out=_null_;
   output out=out atrisk=atrisk order=sorted;
run;

proc print; run;
JacobSimonsen
Barite | Level 11

Proc phreg does not calculate the expected lifetime directly. But PHREG can calculate the survival function, which then can be used to calculate the expected lifetime. It is such that the integrated survival function gives the expected lifetime. One should be carefull in practice, since the survival function can be difficult to estimate in the tail.

 

Here is an example, where the datastep after PHREG do the integration:

data mydata;
  do i=1 to 10000;
    predictor=mod(i,2);
    time=rand('gamma',5*exp(log(2)*predictor));
    censurtime=rand('gamma',10);
    event=(time<=censurtime);
    time=min(time,censurtime);
    output;
  end;
  keep time predictor event;
run;
data covariates;
  do predictor=0 to 1;
output;
  end;
run;
proc phreg data=mydata;
  class predictor /param=glm;
  model time*event(0)=predictor;
  baseline out=kaplanmeier survival=survival  covariates=covariates/method=pl;
run;

data meansurvival;
  set kaplanmeier;
  by predictor;
  retain lasttime;
  if first.predictor then integral=0;
  else do;
    integral+survival*(time-lasttime);
  end;
  lasttime=time;
  if last.predictor;
  put integral;
  keep integral predictor;
run;

 

Unfortunately, it is not possible to estimate confidence limits of the expected survival in this way. If you want this, you should better use a failuretime model (proc lifereg).

chelseaxxlutz
Obsidian | Level 7

Is there a way to get the predicted survival/risk for each observation using proc phreg, not just the number at risk at each time point? For example, using the following, I get a survival and risk for each event/non event observation. But this is using Kaplan Meier/proc lifetest, and I'm hoping there's a way to do it using proc phreg? Thank you!

ods trace on;

ods output productlimitestimates=predkm2;

proc lifetest data=incidentvalid method=km;

test sex agecateg bmicateg diabetes prevhyp prevap prevmi cholcateg smokecateg;

time timedth*death(0);

run;

proc rank data=predkm2 groups=10 out=validkmrank;

var survival;

ranks decile;

run;

proc print data=validkmrank ;

run;

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 6286 views
  • 1 like
  • 5 in conversation