options ps=55 ls=76 nodate nonumber; /* This is alternative method to that described in Kuehn, Section 5.8, pp 158-159. */ title 'SAS Program to determine # of Replications'; title2 '1-Way Random Effects Model'; title3 'STA 6208, Kuehn, Section 5.8'; /* This data step will obtain critical value and power for test with alpha=0.05 */ data sampsize; s2a = 6.81; /* Among Groups variance */ s2e = 5.82; /* Within Groups variance */ t=5; /* This gives the number of groups as variable t */ alpha = 0.05; r_max = 30; trtdf=t-1; /* Degrees of freedom for AMONG Groups */ do r=2 to r_max; /* Loop through potential number of replicates */ errdf=t*(r-1); /* Degrees of freedom for WITHIN Groups */ f_alpha=finv(1-alpha,trtdf,errdf); /* Critical Value for F-test */ power=1-probf((s2e/(s2e+r*s2a))*f_alpha,trtdf,errdf); /* Computes the power of the test */ output; /* Writes line of data to dataset */ end; /* Completes loop of potential replicates */ run; proc print noobs; var r trtdf errdf f_alpha power; run; /* Prints out results, choose r with acceptable power, typically >= 0.80 */ quit;