/* (Programmed by Phil Chapman; revised 9-7-95; send comments or corrections to: pchapman@lamar.colostate.edu) This program calculates power for two sample (one-sided) t-tests. The null hypothesis that mu2 is less than or equal to mu1 is tested versus the alternative that mu2 is greater than mu1. User input values: 1. alpha: the type I error probability. 2. sigma: the standard deviation of the responses. 3. mu1 the true mean for trt 1. 4. mu2 the true mean for trt 2. (mu2 must be > mu1) 5. n1,n2,n3 the sample size (per group) min, max and increment. For example 2,20,2 would calculate power for all even sample sizes from 2 to 20. n1 must be at least 2. To run the program change the values below to the desired values and run the program like any other SAS program. Be sure that you do not type over any semi-colons. The output of the program is a plot and a table, both reporting the same results. The program often gives error messages when the power is very close to 1.0; */ data powert2; * BEGIN USER INPUTS; alpha=0.05; sigma=4.0; mu1=0; mu2=6; n1=2; *n1 must be at least 2; n2=20; n3=1; * END USER INPUTS; do n=n1 to n2 by n3; tcrit=tinv(1-alpha,2*n-2); lambda=abs(mu2-mu1)/(sigma*sqrt(2/n)); power=1-probt(tcrit,2*n-2,lambda); output; end; proc print; var tcrit sigma mu1 mu2 n power; proc plot; plot power*n; run;