* SAS program to calculate sample sizes for CR random effects designs with one-way treatment structure ; * ngrp is the number of factor levels (t) in the completely randomized design ; * P is the percentage increase of sigma_y due to the random effect variance sigma_a^2 that we wish to detect, as illustrated in the text ; %macro powrecr(ngrp,P,alpha,power) ; %local r ndf ddf rat nonc2 fcr pv ; data calc1 ; do r = 2 to 100 ; ndf = &ngrp -1 ; ddf = &ngrp*(r -1) ; rat = (1 + .01*&P)**2 -1 ; nonc2 = 1 + r*rat ; fcr = finv(1-&alpha,ndf,ddf) ; power = 1 -probf(fcr/nonc2,ndf,ddf) ; output ; if power ge &power then leave ; end ; run ; proc print noobs ; title 'Macro POWRECR results' ; run ; proc plot vpercent=90 hpercent=90 ; plot power*r ; title 'Macro POWRECR results' ; run ; %mend ; %powrecr(5,35.,.05,.9) ;