%MACRO logranksize(alloc,psi,y,r1,hr,side,alpha,pi,rho,lfu); /* This Macro complutes the sample size needs, accrual duration, and expected failures for the logrank test, presuming proportional hazards. The alloc parameter, described below is typically 0.50 in Clinical trials, but need not be. The typical study has an accrual rate, a minuimum follow-up period (Y), a control group survival rate at time y, a planning hazard ratio for the experimental group. The program allows for non-exponential survival, by using the parameter rho (the post y to pre y average hazard ratio. Exponential would use 1.0 and "up front accrual" would use 0.0. Losses to follow up by year Y can also be accommodated. None would be zero. Specifically, input fields sre as follows: alloc=fraction allocated to "Treatment 1" psi=total annual accrual rate (both treatments) y=Minimum follow-up in years, assuming no failure or loss to follow-up r1=survival rate for treatment 1 at Y years. hr=Hazard ratio Arm1:Arm2 (proportional hazards presumed) side=sidedness of test (1=1-sided 2=2-sided) alpha=type I error rate, usually 0.05 pi=power, usually 0.80 or 0.90 rho=post y-year to pre-Y yeat hazard rate (1.00=expponential, but usually <1) Value 0 is equivalent to up-front accrual. lfu=loss to follow-up rate at Y-years. Output Accrual Duration (taking account of losses to follow-up) Sample Size (excluding losses to follow-up) Sample Size (including losses to follow-up) Expected total failures */ options ps=60 ls=75; OPTIONS NOSOURCE NONOTES; DATA DDSETX; alloc=&alloc;psi=ψy=&y;r1=&r1;hr=&hr;side=&side;alpha=α pi=πrho=ρlfu=&lfu; output; proc print; data ddsetx;set ddsetx; lam1=-log(r1)/y; lam2=-log(r1)/(hr*y); r2=exp(-y*lam2); del=abs(lam1-lam2); za=-probit(alpha/side); zb=probit(pi); s=del/(za+zb); x=0;inc=1; aa:x=x+inc; q1=r1*(1-exp(-rho*lam1*x))/(rho*lam1*x); q2=r2*(1-exp(-rho*lam2*x))/(rho*lam2*x); p1=1-q1; p2=1-q2; v1=((lam1**2)/(alloc*psi*x*p1)); v2=((lam2**2)/((1-alloc)*psi*x*p2)); s2=sqrt(v1+v2); if s2>s and inc>.9 then goto aa; if inc>.9 then do;inc=.01;x=x-1;goto aa;end; if s2>s then goto aa; n=int(.999+psi*x); na=n/(1-lfu);na=int(na+.999); ex_fail=psi*x*(alloc*p1+(1-alloc)*p2); x=na/psi; data ddsetx;set ddsetx; label alloc='Allocated to Control' psi='Accrual Rate' y='Minimum Follow-up (MF)' r1='Planned control Survival at MF' r2='Planned Experimental Survival at MF' side='Sidedness' alpha='P-Value' pi='power' rho='Post:Pre Y-Yr Haz Ratio' lfu='Loss to Follow-up Rate' x='Accrual Duration' n='Sample size, no losses' na='Sample size with losses' ex_fail='Expected Failures'; ;; proc print label;id alloc; var psi y r1 r2 side alpha pi rho lfu x n na hr ex_fail; title1 'Logrank Planning Parameters per Shuster, Practical Handbook'; title2 'of Sample Size Guidelines for Clinical Trials, CRC Press'; run; %mend; %logranksize(.50,250,2,.7,1.5,2,.05,.8,.01,.2); run;