Contents: | Purpose / Requirements / Usage / Details / Limitations / See Also / References |
%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:
These parameters are optional:
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.
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
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.
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
Beginning in SAS 9.4 TS1M4, the same results can be obtained using the CUSTOM statement in PROC POWER. As described in the documentation of the CUSTOM statement, an exemplary data set is created and the chi-square statistic and degrees of freedom are obtained for this data set. The chi-square statistic is used to provide the noncentrality value (PRIMNC=) in PROC POWER. In this example, the treatments are to have equal sample sizes so a single instance of each is created in the exemplary data set, BB (one instance involves one observation for each response level). Note that this is 4 times the proportion (0.25) of each treatment in the data. Hence, the chi-square statistic is divided by four for use as the noncentrality value.
The following statements produce the power analysis and yields the same power values as the PowerRxC macro above.
data BB; do trt=1 to 4; input p0 p1; y=0; py=p0/(p0+p1); output; y=1; py=p1/(p0+p1); output; end; datalines; .2 .05 .2 .05 .2 .05 .225 .025 ; proc freq data=bb; weight py; table trt*y/chisq; ods output chisq=cs(where=(statistic="Chi-Square")) ; run; data _null_; set cs; call symput('cs',value/4); call symput('df',df); run; proc power; custom dist = chisquare primnc = &cs testdf = &df ntotal = 20, 50, 100 to 1000 by 100 power = .; run;
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
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
Type: | Sample |
Topic: | SAS Reference ==> Procedures ==> FREQ Analytics ==> Nonparametric Analysis Analytics ==> Longitudinal Analysis Analytics ==> Descriptive Statistics Analytics ==> Exact Methods Analytics ==> Categorical Data Analysis SAS Reference ==> Procedures ==> POWER |
Date Modified: | 2020-01-21 11:16:29 |
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 |