* SAS program to calculate sample sizes for the main effect in a CRF design ; * lev_this is the number of factor levels of the main effect of interest ; * lev_other is the number of factor levels of the other main effect ; * rat is equal to: (sum of effect(i)^2)/sigma^2 ; %macro powcrfmain(lev_this,lev_other,rat,alpha,power) ; %local n ndf ddf nonc fcr pv ; data calc1 ; do r = 2 to 10000 ; ndf = &lev_this -1 ; ddf = &lev_this*&lev_other*(r -1) ; nonc = &rat*r*&lev_other ; fcr = finv(1-&alpha,ndf,ddf) ; power = 1 -probf(fcr,ndf,ddf,nonc) ; output ; if power ge &power then leave ; end ; run ; proc print noobs ; title 'Macro POWCRFMAIN results' ; run ; proc plot vpercent=90 hpercent=90 ; plot power*r ; title 'Macro POWCRFMAIN results' ; run ; %mend ; %powcrfmain(3,3,.0693,.05,.9) ; %powcrfmain(3,3,1.513,.05,.9) ;