options ps=65 ls=65; *This is POWERT2.STATISTIC.SAS; *Three files are read into this program. The first is read into rs and contains a correlation matrix for p variables. The second is read into ds and contains effect sizes on the same three variables. The third is read into param and contains the minimum sample size to be considered for the study, the maximum sample size to be considered for the study, alpha, and the target power.; data rs; input var1-var3; datalines; 1.00 .25 .50 .25 1.00 .33 .50 .33 1.00 data ds; input d1-d3; datalines; .5 .5 .2 data param; input minn maxn alpha tpower; datalines; 2 200 .05 .80 proc iml; edit rs; read all into r; print r; edit ds; read all into d; print d; edit param; read all into temp1; minn=temp1[1,1]; maxn=temp1[1,2]; prob=1-temp1[1,3]; target = temp1[1,4]; p=nrow(r); ptest=ncol(d); if p ^= ptest then do; print ' ERROR '; print 'number of effect sizes and number of variables are not equal'; minn=maxn + 1; end; do ii = 1 to p; do jj = ii+1 to p; if r[ii,jj] ^= r[jj,ii] then do; print ' ERROR '; print 'the correlation matrix is not symmetric'; minn=maxn + 1; end; end; end; if minn <= p+1 then minn = p+2; do n=minn to maxn; DF2 = N + N - P -1; nc=(n/2)*d*inv(r)*d`; cval=FINV(prob,P,DF2); POWER = 1 - PROBF(cval,P,DF2,NC); if n=maxn then do; if power < target then do; print 'Sample too small, raise maximum size'; print n nc cval power; end; end; if power > target then do; print 'Power calculations have been completed'; print n nc cval power; print 'Note. N is the reqired number of Ss in each treatment'; n=maxn; end; end; quit;