options ps=55 ls=76 nodate nonumber; /* This is alternative method to that described in Kuehn, Section 2.14, pp 63-65. */ title 'SAS Program to determine # of Replications'; title2 'Completely Randomized Design'; title3 'STA 6207, Kuehn, Section 2.10'; /* This data step will obtain critical value and power for test with alpha=0.05 */ data sampsize; t=3; /* This gives the number of treatments as variable t */ tau1=0.5; /* Selected effect for treatment 1 */ tau2=-0.2; /* Selected effect for treatment 2 */ tau3=-0.3; /* Selected effect for treatment 3 */ sigma2=0.22; /* Estimate of variance from pilot study */ sumtau2=(tau1**2)+(tau2**2)+(tau3**2); /* Sum of squared effects */ do r=3 to 30; /* Loop through potential number of replicates */ trtdf=t-1; /* Degrees of freedom for TREATMENTS */ errdf=t*(r-1); /* Degrees of freedom for ERROR */ f_alpha=finv(.95,trtdf,errdf); /* Critical Value for F-test (alpha=.05) */ lambda=r*sumtau2/sigma2; /* Non-Centrality parameter for selected effects */ power=1-probf(f_alpha,trtdf,errdf,lambda); /* 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 lambda power; run; /* Prints out results, choose r with acceptable power, typically >= 0.80 */ quit;