options pagesize=65 linesize=65; data one; omegas=.03 ; *population omega squared; alpha=.05 ; *Type I error rate; tpower=.70 ; *Target power; maxn= 2000 ; *Maximum sample size for calculations; prod=6 ; *product of number of levels of the all factors; df1=2 ; *degrees of freedom for the interaction; rho=.00 ; *correlation between covariate and dependent variable. Equal to zero if there is no covriate; prob=1-alpha; do n=2 to maxn; lambda=n*prod*omegas/((1-omegas)*(1-rho**2)); df2=prod*(n-1);if rho^=0 then df2=df2-1; cval=finv(prob,df1,df2); power=1-probf(cval,df1,df2,lambda); if power lt tpower and n = maxn then do; comment = 'raise maxn '; array x1 cval power;; do over x1; x1=round(x1,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; cell_n=n; array x2 cval power cell_n; do over x2; x2=round(x2,.01); end; output; n=maxn; end; end; proc print noobs; title1 ' '; title2 ' '; var comment prod alpha omegas rho tpower power cell_n; run; quit;