@spud704. Yes you can do exactly this test much more timeefficient than the approach you suggest. Just aggregate on riskset and weight on the numbers at risk. Use the attached macro for the article.
In this little program piece I simulate a dataset with one covariate, such that there is a rateratio=1.5 for 1<=5 and rateratio=2 for t>5 (so not proportional hazard rates since the rateratio changes. Then I estimate first the overall rateratio, then the rateratio in the two intervals, and then the test for proportional hazardrate by constructing the log(time)xcovariate and test this variable out of the model. The same three models are then made on the aggregated dataset, - you will notice that the numbers are exactly the same, it just run much faster.
data simulation;
do covariate1=0 to 1;
do i=1 to 2000;
baseline=0.1;
rateratio1=1.5;
rateratio2=2;
t=rand('exponential',1/(baseline*rateratio1**(covariate1=1)));;
if t>5 then t=5+rand('exponential',1/(baseline*rateratio2**(covariate1=1)));;
entry=0;
event=1;
output;
end;
end;
drop i;
run;
proc phreg data=simulation nosummary;
class covariate1/param=glm ;
model (entry t)*event(0)=covariate1;
run;
proc phreg data=simulation nosummary;
covariate1_1=covariate1*(t<=5);
covariate1_2=covariate1*(t>5);
model (entry t)*event(0)=covariate1_1 covariate1_2/rl;
run;
proc phreg data=simulation nosummary;
logt=log(t)*covariate1;
class covariate1/param=glm ;
model (entry t)*event(0)=covariate1 logt/rl;
run;
*equivalent to:;
%coxaggregate(data=simulation,output=dataout,entry=entry,exit=t,event=event,covariate=covariate1);
proc phreg data=dataout nosummary;
class covariate1(ref="0") period/param=glm ;
model dummytime*dummytime(2)= covariate1 ;
hazardratio covariate1;
strata time ;
freq weight;
run;
data dataout;
set dataout;
period=(time<=5);
logt=log(time);
run;
proc phreg data=dataout nosummary;
class covariate1(ref="0") period/param=glm ;
model dummytime*dummytime(2)= covariate1*period ;
hazardratio covariate1/at(period=all);
strata time ;
freq weight;
run;
proc phreg data=dataout nosummary;
class covariate1(ref="0")/param=glm ;
model dummytime*dummytime(2)=covariate1 covariate1*logt/type3 ;
strata time ;
freq weight;
run;
Good luck.
... View more