options pagesize=65 linesize=65; data one; es=.50 ; *Effect size for largest and smallest mean; alpha=.05 ; *Type I error rate; j=6 ; *Number of levels for the the between-subjects factor for which es is define. j is limited to 6 or less; tpower=.70 ; *Target power; maxn= 200 ; *Maximum sample size for calculations; prod=1 ; *product of number of levels of the other factors. Equals 1 for a single factor design and equals the number of level in the other factor for a two-factor design; rho=.00 ;*correlation between covariate and dependent variable. Equal to zero if there is no covariate; * for j=3 specify mu2 for j=4 specify mu2 and mu3 for j=5 specify mu2, mu3, and mu4 for j=6 specify mu2, mu3, mu4, and mu5 All specifications must be bettween 0 and es; mu2 = .10 ; mu3 = .15 ; mu4 = .35 ; mu5 = .40 ; prob=1-alpha; df1=j-1; mu1=0; if j = 2 then do; mu2=es; end; if j =3 then do; mu3=es; end; if j =4 then do; mu4=es; end; if j = 5 then do; mu5=es; end; if j = 6 then do; mu6=es; end; if j=3 then do; gm=(mu1 + mu2 + mu3)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 ); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*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 mu1 mu2 mu3; do over x1; x1=round(x1,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x2 cval power mu1 mu2 mu3; do over x2; x2=round(x2,.01); end; output; n=maxn; end; end; end; if j=4 then do; gm=(mu1 + mu2 + mu3 + mu4)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*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 x5 cval power mu1 mu2 mu3 mu4; do over x5; x5=round(x5,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x6 cval power mu1 mu2 mu3 mu4; do over x6; x6=round(x6,.01); end; output; n=maxn; end; end; end; if j=5 then do; gm=(mu1 + mu2 + mu3 + mu4 + mu5)/ j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*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 x13 cval power mu1 mu2 mu3 mu4 mu5; do over x13; x13=round(x13,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x14 cval power mu1 mu2 mu3 mu4 mu5; do over x14; x14=round(x14,.01); end; output; n=maxn; end; end; end; if j=6 then do; gm=(mu1 + mu2 + mu3 + mu4 + mu5 + mu6)/j; delta = ((mu1-gm)**2 + (mu2-gm)**2 + (mu3-gm)**2 + (mu4-gm)**2 + (mu5-gm)**2 + (mu6-gm)**2); do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*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 x21 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x21; x21=round(x21,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x22 cval power mu1 mu2 mu3 mu4 mu5 mu6; do over x22; x22=round(x22,.01); end; output; n=maxn; end; end; end; if j =2 then do; mu1 = .00; mu2 = es; gm=(mu1 + mu2)/j; delta = (mu1-gm)**2 + (mu2-gm)**2; do n=2 to maxn; lambda=n*prod*delta/(1-rho**2); df2=j*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 x31 cval power mu1 mu2 mu3; do over x31; x31=round(x1,.01); end; output; end; if power ge tpower then do; comment ='analysis ok'; array x32 cval power mu1 mu2 mu3; do over x32; x32=round(x32,.01); end; output; n=maxn; end; end; end; data two; set one; if j=2; cell_n=n; proc sort; by n; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var mu1 mu2 cell_n power ; data three; set one; if j=3; cell_n=n; proc sort; by n; data threea; set three; if _n_=1; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs data=three; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var mu1 mu2 mu3 cell_n power ; data four; set one; if j=4; cell_n=n; proc sort; by n; data foura; set four; if _n_=1; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs data=four; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var mu1 mu2 mu3 mu4 cell_n power ; data five; set one; if j=5; cell_n=n; proc sort; by n; data fivea; set five; if _n_=1; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs data=five; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var mu1 mu2 mu3 mu4 mu5 cell_n power ; data six; set one; if j=6; cell_n=n; proc sort; by n; data sixa; set six; if _n_=1; proc print noobs; title1 ' '; title2 ' '; var comment j prod es rho alpha tpower ; proc print noobs data=six; title1 'origin is set so that smallest mean equals zero'; title2 'means are in standard deviation units'; var mu1 mu2 mu3 mu4 mu5 mu6 cell_n power ; proc datasets; delete one; quit; run;