Programming the statistical procedures from SAS

proc phreg predicted time to event

Reply
Contributor lei
Contributor
Posts: 38

proc phreg predicted time to event

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

 

Super User
Posts: 20,731

Re: proc phreg predicted time to event

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?

SAS Super FREQ
Posts: 3,839

Re: proc phreg predicted time to event

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;
Super Contributor
Posts: 301

Re: proc phreg predicted time to event

[ Edited ]

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).

Occasional Contributor
Posts: 8

Re: proc phreg predicted time to event

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;

 

Ask a Question
Discussion stats
  • 4 replies
  • 664 views
  • 0 likes
  • 5 in conversation