options nonotes nosource; %macro GEHAN(eesetx,time,surv,rx,conf); /* Samle Usage:: %GEHAN(ctrial,dis_time,dis_event,treatment,.95); Input: Arguments are as follows (after = sign): eesetx=ctrial user supplied data set. time=dis_time quantitative survival time (e.g. time to discharge in this case) surv=dis_event (0 censored, patient never met discharge griteria or =1 uncensored (patient met discharge criteria) rx=treatment (treatment's a numerical variable defining the treatment number only two allowed.) Conf=Confidence coefficinet for 100conf% confidence interval (e.g. .95 will give you 95%) Output: The output gives you the sample sizes, the point and interval estimates for Rho (lower number treatment is matched to rho times higher. Values below 1.00 mean the lower numbered treatment is expected to have lower numeric outcomes.) Note: If there is no censoring, the interval will match within roundoff to the Wilcoxon scale macro. Cautions: (a) If you have more than two treatments, the treatments compared are the lowest two numbers. (b) There are no titles or original variable names. To keep track, add a title before invoking the macro. See the example below for sample details. (c) The grid search is more intensive for values of rho below 1.00, and thus we advise you to use as the lower treatment, the group that tends to have lower values. For example, in an intervention study, use active treatment as treatment 1 and control as treatment 2. (d) To expand upon (c), if the program does not deliver the full point and interval estimates, you need to reverse the treatment order, as one or more of the output variables exceeds 10.0. The output with the data set below is point estimate=0.39 95% CI (0.22-0.73) If you reverse the treatment order you will get point estimate=2.55 (1/0.39) 95% CI (1.38-4.4) */ data fff;sham=.;output; %do irho=1 %to 240; data dq;set dq;if rho=. then rho=0.00; rho=rho+.01; if rho>1.001 then rho=rho+.01; if rho>2.001 then rho=rho+.03; if rho>3.001 then rho=rho+.05; data dd;set dq; time=&time; surv=&surv; rx=℞ keep time rx surv rho;if time=. or rx=. or surv=. then delete; proc sort;by rx; proc means noprint;by rx;var rho; output out=admin mean=my; data admin;set admin;if rx=. then delete; data admin;set admin;kk=_n_; data admin;set admin;if kk in (1,2); data dd;merge dd admin;by rx; rx=kk; if rx=2 then time=time*rho; data d1;set dd;time1=time; if time=. or surv=. then delete; surv1=surv;xxx=1; proc sort;by xxx rx; data d1;set d1;j=_n_; proc means noprint;by xxx;var rx; output out=nnew n=nt; data d1;merge d1 nnew;by xxx; data d2;set d1; do k=1 to nt;output;end; proc sort;by k; data d3;set d1;k=j;time2=time1;surv2=surv1;keep k time2 surv2; proc sort;by k; data d3;merge d2 d3;by k; u=0;if surv1=1 and surv2=1 then do;if time1>time2+.000001 then u=-1; if time1time2-.000001 then u=-1; if surv2=0 and surv1=1 and time2>time1-.000001 then u=1; keep k time rx surv1 surv2 time1 time2 nt u; proc sort;by k; data d4;set d1;k=j;keep k rx; proc sort;by k; data sum;set d3;proc means noprint;by k; var u;output out=grank sum=grank; data sum;merge grank d4;by k; run; data sum;set sum;xxx=1; proc sort;by xxx; proc means noprint ;var grank;by xxx;output out=f std=sigmau n=nt; data sum2;set sum;if rx=1; proc means noprint ;var grank;by xxx;output out=rx1 sum=sumu1 n=n1; data admin;set admin;if kk=1;xxx=1;proc sort;by xxx; data final;merge f rx1;by xxx; data final;merge final admin;by xxx; se=sigmau*sqrt(n1*(nt-n1)/(nt));z=sumu1/se; p_val=2*probnorm(-abs(z));chisq=z**2; n2=nt-n1; /* file print;put // @10 'Gehan-Wilcoxon Test'; put // @10 'Sample Sizes for Rx 1 and Rx 2= ' n1 ' and ' n2; put // @10 'Rho, the multiplier of each entry in Treatment 2= ' my; put // @10 'Sum of Gehan Ranks on RX 1=' sumu1; put // @10 'Z-statistic=' z best5.; put // @10 'Chi-sq=z**2=' chisq best5. ; put // @10 'Two-sided P-value=' p_val best7.; */ data fff;set fff final; run; %end; data fg;set fff;if my<.0001 then delete;c=&conf;p=1-c; if p=. or p>1 then p=.05; tag1=0; if old1>p and p_val

p then tag1=1; if old1>p_val and old1>old2 and old1>.7 then tag1=2; if tag1>.1 then output; oldmy=my; old2=old1; old1=p_val; retain old1 old2 oldmy; data fg;set fg;xxx=1; data f1;set fg;if tag1=1;lcl=oldmy;keep lcl n1 n2 p xxx; proc sort;by xxx; data f3;set fg;if tag1=3;ucl=my;keep ucl xxx; proc sort;by xxx; data f2;set fg;if tag1=2;point_est=oldmy;keep point_est xxx; proc sort;by xxx; data f;merge f1 f2 f3;by xxx;conf=100*(1-p); file print; put // @10 'Point and ' conf z4.2 '% confidence limits for scale via Gehan method'; put // @10 'Sample sizes = ' n1 ' and ' n2; put // @10 'Point Est=' point_est @30 'Conf Interval for rho=(' lcl ' , ' ucl ' )'; %mend; run; /* A sample application */ data d; input time @@;r=1;cards; 22 25 21 87 28 20 47 23 68 20 31 20 19 22 23 30 27 54 51 18 53 46 23 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 data e;input time @@;r=2;cards; 71 97 21 46 43 78 46 68 47 70 78 23 95 29 127 101 31 89 79 76 148 94 54 78 30 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 20000 data dq;set d e;cens=1;if time>10000 then cens=0; proc sort;by r;title 'Time to meet discharge criteria'; %GEHAN(dq,time,cens,r,.95); run; +