Don't panic. There is a good trick you can use. Because you define your covariate inside phreg the algorithm it use will change to a slower algorithm were calculation speed is proportional to N^2. (N=number of events). What you can do is to aggregate your data on riskset, then you get a dataset with a timevariable that indicate the time of the riskset. then you can define your covariate in a dataset before using phreg. calculation time of Phreg will then only be proportional to N. It is not that simple, but you can use my macro Here: how to speed up phreg. Using the macro your program will be much like this example: data simulation;
do covariate1=0 to 1;
do covariate2=0 to 1;
do i=1 to 100;
*the timevariables are created such that ties will happens often;
t=floor(-1000*log(ranuni(-1))/exp(0.1*(covariate1=1)+0.2*(covariate2=1)))/10+0.1;
*a censoring variable c;
c=-100*log(ranuni(-1));
*events happens if survival time are less than censoring time;
event=(t<c);
exit=min(t,c);
entry=0;
output;
end;
end;
end;
drop i t c;
run;
quit;
*Example , a timedependent effect;
proc phreg data=simulation nosummary;
covariate1_1=(exit<=5)*covariate1;
covariate1_2=(exit>5)*covariate1;
model (entry exit)*event(0)= covariate1_1 covariate1_2;
run;
*equivalent to:;
%coxaggregate(data=simulation,output=dataout,entry=entry,exit=exit,event=event,covariate=covariate1);
data dataout;
set dataout;
more5=(time>5);
run;
proc phreg data=dataout nosummary;
class covariate1 more5/param=glm ;
model dummytime*dummytime(2)= covariate1*more5 ;
hazardratio covariate1/ at( more5=all);
strata time ;
weight weight;
run;
... View more