Programming the statistical procedures from SAS

proc phreg predicted time to event

Reply
Contributor lei
Contributor
Posts: 37

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

 

Grand Advisor
Posts: 16,893

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,307

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: 271

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

Ask a Question
Discussion stats
  • 3 replies
  • 258 views
  • 0 likes
  • 4 in conversation