/* Two-Sample Z-Test for quantitative or binomial data Input Data mu1=Hypothesized Mean (Control) (Or Proportion Success) mu2=Hypothesized Mean (Experimental) (Or Proportion Success) sigma1=Standard Deviation (Control) (Missing for Proportions) sigma2=Standard Deviation (Experimental)(Missing for Proportions) alpha=Type I error Power=Power Side=1 (one-sided) or =2 (Two-sided) Output: n=Sample Size (Per Group) NB: If sigma1=0, you can get single sample results. */ data a;input mu1 mu2 sigma1 sigma2 alpha power side; if alpha>1 then alpha=.01*alpha; if power>1 then power=.01*power; za=-probit(alpha/side); zb=probit(power); if sigma1<-.001 or sigma2<-.001 then do; if mu1>1 then mu1=.01*mu1; if mu2>1 then mu2=.01*mu2; if sigma1<-.001 then sigma1=sqrt(mu1*(1-mu1)); if sigma2<-.001 then sigma2=sqrt(mu2*(1-mu2)); end; del=mu2-mu1; n=int(1+(sigma1**2+sigma2**2)*(((za+zb)/del)**2)); cards; .1 .3 . . .05 .8 1 0 .2 0 .3 .05 .8 2 50 70 . . .05 .8 1 .50 .70 .5 .46 .05 .8 1 4 6 2 3 .05 .8 2 proc print; data a;set a; file print; k=_n_; if k=1 then do; put @10 'Asymptotic Sample Size Per Group'; put @10 'If one sigma=0 this is for Paired Z'; put @8 'Diff' @16 'SIGMA1' @24 'SIGMA2' @32 'N' @38 'Power' @46 'ALPHA' @54 'Sided'; end; put @8 del best6. @16 sigma1 best6. @24 sigma2 best6. @32 n @38 power @46 alpha @54 side; run;