From: Garnett McMillan on
A little while back I posted a message about difficulties using PROC
MIXED for power analysis following chapter 12 in SAS System for Mixed
Models. I've since been in contact with Walt Stroup who identified
some errors in chapter 12. Below is a revision of code for section
12.2.

The revision uses the variance components estimates for the original
dataset in the replicate data analysis and power calculations.

title1 "Output 12.1 from the book";
ods select covparms tests3 ;
proc mixed data=mice nobound cl ;
class cage condition diet;
model gain= condition|diet / solution ddfm=satterth;
random cage cage*condition;
ods output tests3=t3 ;
run;

data f_power;
set t3;
Noncen = NumDF*FValue;
Alpha = 0.05;
FCrit = finv(1-Alpha,NumDF,DenDF,0);
Power = 1 - probf(FCrit,NumDF,DenDF,Noncen);
run;

title1 "Output 12.1 from the book (continued) ";
proc print data=f_power;
run;

data Mice1;
set mice;
cage = cage+6;
data mice2;
set mice mice1;
run;

title1 "REVISED Output 12.2 from the book";
ods select tests3;
proc mixed data=mice2 nobound cl noprofile; **** Do not profile the
likelihood for resid. variance;
parms (5.0292) (-6.2415) (31.5567)/ noiter ; **** use var comp
ests from original dataset;
class cage condition diet;
model gain=condition|diet /s ddfm=satterth;
random cage cage*condition;
ods output tests3 = tAug;
run;

data f_power2;
set tAug;
Alpha = 0.05;
Noncen = NumDF*FValue;
FCrit = finv(1-Alpha,NumDF,DenDF,0);
Power = 1 - probf(FCrit,NumDF,DenDF,Noncen);
run;

title1 "REVISED Output 12.3 from the book";
proc print data=f_power2;
run;