/* This program uses PROC IML in SAS to compute sample sizes for 2-sample t-tests It is posted as power2t.sas */ proc iml; start size2; alpha = .05; /* specify the type I error level */ power = .90; /* specify the power of the test */ beta = 1 - power; /* Compute the type II error level */ d = 1.0/1.25; /* specify difference to be detected divided by standard error for one observation */ ratio=1.0; /* Ratio of sample sizes n1/n2 */ n2 = ((1+(1/ratio))*(probit(alpha/2) + probit(beta))**2)/(d*d); n1 = ratio*n2; n2 = int(n2)+1; /* round up to next largest integer */ n1 = int(n1)+1; v = (n1+n2-2); /* Compute degrees of freedom */ n2 = ((1+(1/ratio))*(tinv(alpha/2,v) + tinv(beta,v))**2)/(d*d); n1 = ratio*n2; n2 = int(n2) + 1; /* round up to next largest integer */ n1 = int(n1) + 1; print,, " Sample sizes for two-sample t-tests" ; print " Significance level: " alpha; print " power: " power; print " Scaled difference: " d; print " Ratio of sample sizes n1/n2: " ratio; print " Sample size (two-sided test): n1= " n1; print " n2= " n2; /* Compute sample size for a one-sided two-sample t-test */ n2 = ((1+(1/ratio))*(probit(alpha) + probit(beta))**2)/(d*d); n1 = ratio*n2; n2 = int(n2) + 1; n1 = int(n1) + 1; v = (n1+n2-2); n2 = ((1+(1/ratio))*(tinv(alpha,v) + tinv(beta,v))**2)/(d*d); n1= ratio*n2; n2 = int(n2) + 1; n1 = int(n1) + 1; print " Sample sizes (one-sided test): n1=" n1; print " n2=" n2; finish; run size2;