/* Last revised October 21, 1996. (Requires at least SAS Version 6.11) Send comments or corrections to: pchapman@lamar.colostate.edu This program estimates power for the Pearson Chi-square test of independence in two-way (r by c) tables. User inputs: r=number of rows c=number of columns An r by c array of probabilities for which power is to be computed (These must sum to one, and are entered after the "cards" statement.) alpha=the type I error rate for the hypothesis test. n1=the min total sample size (all cells) considered n2=the max total sample size considered n3=the increment in total sample size considered */ data powchi; r=2; c=4; do i=1 to r; do j=1 to c; input prob @@; output; end; end; cards; .15 .15 .1 .1 .1 .1 .15 .15 ; proc freq; weight prob; tables i*j/nocol norow nopercent; proc freq noprint; weight prob; tables i*j /chisq; output out=out1 chisq; data pow2; set out1; alpha=0.05; n1=100; n2=400; n3=20; crit=cinv(1-alpha,df_pchi); do n=n1 to n2 by n3; power=1-probchi(crit,df_pchi,n*_pchi_); output; end; proc print; var alpha df_pchi _pchi_ n power; run;