%macro fulltest(ds,time,status,str); /***********************************************************/ /* Calculate the Renyi and Cramer-von Mises tests, of Klein*/ /* and Moeschberger sections 7.6-7. */ /***********************************************************/ ods output ProductLimitEstimates=out1; proc lifetest nocens data=&ds ; time &time*&status(0); strata &str; run; proc sort data=out1; by &time censor; run; data out1; set out1; retain nf1 nf2 0 nl1 nl2; by &time censor; if time=0 or last.censor then; else delete; if &str=1 then do; nf1=failed; nl1=left; end; else do; nf2=failed; nl2=left; end; run; data out2; set out1; by &time censor; retain ts va mts mats chd cmvt chdv lf1 lf2 0; temp=1; nd1=nf1-lf1; lf1=nf1;nd2=nf2-lf2; lf2=nf2; /***********************************************************/ /* nd1=number of events in stratum 1 */ /* nl1=number at risk in stratum 1 */ /* p1=proportion with event in stratum 1 */ /* Similarly for nd2,nl2,p2,ndt,nlt,pt for stratum 2, total*/ /* ts=running log rank statistic, va=running var. */ /* chd=running cumulative hazard difference */ /* chdvc=variance contribution for chd */ /* chdv=running variance for chd */ /* cmvt=running Cramer-von Mises statistic */ /***********************************************************/ if &time=0 then do; nd1=0; nd2=0; end; nl1=nl1+nd1; nl2=nl2+nd2; nlt=nl1+nl2; ndt=nd1+nd2; if nd1>0 then p1=nd1/nl1; else p1=0; if nd2>0 then p2=nd2/nl2; else p2=0; if ndt>0 then pt=ndt/nlt; else pt=0; chd=chd+p2-p1; chdvc=nd1*p1**2+nd2*p2**2; cmvt=chd**2*chdvc+cmvt; chdv=chdv+chdvc; tc=nl1*(pt-p1); if tc=. then; else ts=ts+tc; vc=(nl1/nlt)*(1-nl1/nlt)*ndt*(nlt-ndt)/(nlt-1); if vc=. then; else va=va+vc; mts=max(ts,mts); mats=max(abs(ts),mts); if ndt=0 then delete ; run; run; proc print noobs data=out2; var &time nd1 nd2 nl1 nl2 tc ts vc va cmvt chdv; run; data out2; set out2; by temp; if last.temp then; else delete; mts=mts/sqrt(va); mats=mats/sqrt(va); cmvt=cmvt/chdv**2; run; proc print noobs data=out2; var mts mats cmvt; run; %mend;