1

Computes power for testing prop=const where prop and const are observed and expected (constant) proportions respectively, ntot is the total sample size and alpha is the (two-tailed) type I error. Power computation is also available using a spreadsheet and in R.

[COPY AND PASTE THE SYNTAX BELOW INTO A SPSS SYNTAX WINDOW AND RUN; SET DATA AS DESIRED]

DATA LIST free
/prop const ntot alpha. 
BEGIN DATA. 
0.45 0.5 900 .05 
END DATA. 
set errors=none.
matrix.
get m /variables=prop const ntot alpha /missing=omit.
compute prop=make(1,1,0).
compute const=make(1,1,0).
compute ntot=make(1,1,0).
compute alpha=make(1,1,0).
compute prop=m(:,1).
compute const=m(:,1).
compute ntot=m(:,2).
compute alpha=m(:,3).
end matrix.
COMPUTE #chisq1 = ((prop-const)**2)/(const*(1-const)).
compute #df=1.
compute #conf = 1-alpha.
compute #chisq=ntot*#chisq1.
compute power = 1 - NCDF.CHISQ(IDF.CHISQ(#conf,#DF),#DF,#CHISQ).
formats prop (f5.2) const (f5.2) alpha (f5.2) ntot (f5.2) power (f5.2).
variable labels prop 'Proportion' const 'Constant' /alpha 'Two-Tailed Alpha' /ntot 'Total Sample Size' /power 'Power'.
report format=list automatic align(center)
  /variables=prop const alpha ntot power 
  /title "Power for given sample size for One sample test for a single proportion" .