Contents: |
Purpose / Requirements / Usage / Details / Limitations / See Also / References |

*PURPOSE:*- Computes approximate power for Pearson and Likelihood Ratio chi-square tests of independence in PROC FREQ.
*REQUIREMENTS:*- Only Version 6 or later of Base SAS Software is required.
*USAGE:*-
Follow the instructions in the Downloads tab of this
sample to save the %POWERRxC macro definition. Replace the text within quotes in the following statement with the location of the %POWERRxC macro definition file on your system. In your SAS program or in the SAS editor window, specify this statement to define the %POWERRxC macro and make it available for use:
%inc "<location of your file containing the POWERRxC macro>";

Following this statement, you may call the %POWERRxC macro. See the Results tab for an example.

The following parameters are required:

**ROW=***variable*- Specifies the variable defining the rows of the table.
**COL=***variable*- Specifies the variable defining the columns of the table.

These parameters are optional:

**DATA=**- Specifies the SAS data set to be analyzed. If the DATA= option is not supplied, the most recently created SAS data set is used.
**COUNT=***variable*- Specifies a variable containing the cell counts of the table. Omit this option if each observation in the DATA= data set represents only a single entry in the table. This variable, if specified, is used in the WEIGHT statement in PROC FREQ.
**LEVEL=***value*- Specifies the significance level or size of the test. This is the limit you place on the probability of a type 1 error. The specified value should be between 0 and 1. The default value is 0.05 which sets the probability of a type 1 error at 0.05.
**NRANGE=***value*|*value-list*- Specifies the sample size or list of sample sizes for
which approximate power is to be computed. If
omitted, the actual sample size is used. You may
specify a list of values separated by commas, a range
of the form
or*x*TO*y*, or a combination of these. However, you must surround the NRANGE= value with*x*TO*y*BY*z***%str( )**if any commas appear in it. For example,- nrange=20 to 200 by 20
- nrange=%str(20,50,100,140)
- nrange=%str(10, 20, 50 to 100 by 10)

*DETAILS:*- Agresti (1990 and 2002) discusses the details of computing approximate power for Pearson and deviance chi-square tests in contingency tables using the noncentral chi-square distribution.
*LIMITATIONS:*- Limited error checking is done. If the DATA= option is specified, be sure the named data set exists. If DATA= is not specified, a data set must have been created previously in the current SAS session. Be sure that the variables specified in the ROW=, COL= and COUNT= options exist in the data set. You can run PROC CONTENTS on the data set prior to using this macro to verify the data set name and the names of variables.
*SEE ALSO:*-
- Discussion of power analysis for 2x2 tables
- %POWER2x2 macro to compute power of a test comparing two independent proportions.
- %POWER macro to calculate power-related measures for retrospective and prospective analyses for linear models fit to normal responses.

*REFERENCES:*-
Agresti, A. (1990 and 2002),
*Categorical Data Analysis*, New York: John Wiley & Sons, Inc.

These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.

These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.

*EXAMPLE 1:*-
In this example, each
observation is a total cell count instead of a single cell entry, so a count
variable (FREQ) is created to hold the cell counts. The observed
sample size is used for computing approximate power.
data a; do row=1 to 2; do col=0,1; input freq @@; output; end; end; datalines; 3 11 6 2 ; /* Define the POWER2x2 macro */ %inc "<location of your file containing the POWERRxC macro>"; %powerRxC(row=row, col=col, count=freq)

*RESULTS:*-
Approximate Power of Chi-square Tests for Independence Test Level=.05 Power of Power Pearson of L.R. n Chi-square Chi-square 22 0.69093 0.70345

*EXAMPLE 2:*-
This example is identical to the previous one except that raw, individual data are used instead of summarized, cell-count data. That is, each observation in data set AA contributes a count of one in one cell of the table. With individual data, a count variable is not needed.
data aa; do row=1 to 2; do col=0,1; input freq @@; do i=1 to freq; drop i freq; output; end; end; end; datalines; 3 11 6 2 ; %powerRxC(row=row, col=col)

*RESULTS:*- The results are identical to Example 1.
*EXAMPLE 3:*-
Suppose subjects are to be given one of four treatments and a
binary response will be recorded for each subject resulting in a
4x2 table. Determine the sample size needed to detect a 0.1
difference in response probabilities with adequate power. This is
done by entering cell values that exhibit the worst case scenario
-- three rows with response probability .2 (=.05/(.2+.05)) and one
row with response probability .1 (=.025/(.225+.025)). Treatment
sample sizes are to be equal, so the marginal row (treatment) probabilities are
all 0.25. Here, column 2 is regarded as the response category,
though the columns could be reversed without effect.
data bb; do trt=1 to 4; do response=0,1; input prob @@; output; end; end; datalines; .2 .05 .2 .05 .2 .05 .225 .025 ; %powerRxC(row=trt, col=response, count=prob, nrange=%str(20,50,100 to 1000 by 100))

*RESULTS:*-
Approximate Power of Chi-square Tests for Independence Test Level=.05 Power of Power Pearson of L.R. n Chi-square Chi-square 20 0.06570 0.06735 50 0.09111 0.09562 100 0.13763 0.14762 200 0.24106 0.26305 300 0.34986 0.38282 400 0.45603 0.49715 500 0.55420 0.59999 600 0.64131 0.68842 700 0.71608 0.76178 800 0.77855 0.82086 900 0.82955 0.86728 1000 0.87038 0.90299

*EXAMPLE 4:*-
Example from Agresti (1990) pp 241-243. Column 1 probabilities for
each row are hypothesized to be .63 and .57. Row sample sizes are
to be equal, so the marginal row probabilities are both 0.5.
data c; do row=1 to 2; do col=0,1; input freq @@; output; end; end; datalines; .315 .185 .285 .215 ; %powerRxC(data=c, row=row, col=col, count=freq, nrange=%str(20,50 to 200 by 50))

*RESULTS:*-
Approximate Power of Chi-square Tests for Independence Test Level=.05 Power of Power Pearson of L.R. n Chi-square Chi-square 20 0.05864 0.05864 50 0.07174 0.07176 100 0.09395 0.09398 150 0.11651 0.11656 200 0.13935 0.13941

*EXAMPLE 5:*-
Get power for a .10 level test performed on previously-collected
data.
data d; input type $ sex $ ; datalines; a m b m c f b m c f c f b f a m a f a m b m c f b m c f c f b f a m a f ; %powerRxC(row=type, col=sex, level=.10)

*RESULTS:*-
Approximate Power of Chi-square Tests for Independence Test Level=.10 Power of Power Pearson of L.R. n Chi-square Chi-square 18 0.77402 0.87034

Right-click on the link below and select **Save** to save
the %POWERRxC macro definition
to a file. It is recommended that you name the file
`powerrxc.sas`

.

Download and save powerrxc.sas

Computes approximate power for Pearson and Likelihood Ratio
chi-square tests of independence in PROC FREQ.

#### Operating System and Release Information

Type: | Sample |

Topic: | SAS Reference ==> Procedures ==> FREQ Analytics ==> Nonparametric Analysis Analytics ==> Longitudinal Analysis Analytics ==> Descriptive Statistics Analytics ==> Exact Methods Analytics ==> Categorical Data Analysis |

Date Modified: | 2007-08-14 03:03:07 |

Date Created: | 2005-01-13 15:03:36 |

Product Family | Product | Host | SAS Release | |

Starting | Ending | |||

SAS System | SAS/STAT | All | n/a | n/a |