Using SAS 9.4
I am running a post-hoc power analysis (I understand it is not a great method but it is a request so I have to complete it). I have 2 groups with a total n=62 (group 1 n=49, group 2 n=13). With an alpha of 0.05 and the power set to 0.8, I want to find out what n would be needed in group 2 to show significance between the groups. I found the code below in the SAS help center but I am not sure my setup is correct. Specifically, I am not sure if I have the group proportions correct. Any help would be appreciated. Thank you
proc power;
twosamplefreq test=fisher
groupproportions= (.79 .21)
alpha= .05
npergroup=.
power= .8;
run;
proc power provides a calculation of the power of the exact binomial test for the proportion of events in a single sample. To calculate the power of detecting a difference in the number of events and non-events within a sample of size 62, when the event probability is 0.21 (= 13/62), you can do:
proc power;
onesamplefreq
test = exact
ntotal = 62
nullproportion = 0.5
alpha = 0.05
proportion = 0.21 /* = 13 / 62 */
power = .;
run;
The groupproportions= option should specify the proportions of events in both groups, NOT the proportions of the group sizes to the total size. For a post-hoc analysis you would most likely write the observed proportions as the group proportions. If for example you observed 31/49 events in group 1 and 6/13 events in group 2, you would write groupproportions=0.63 0.46
Note that you cannot keep one of the group sizes fixed and ask for the size of the other group in proc power. One way to do it anyway is to ask for the power and adjust iteratively the size of the second group until you get the power that you want
proc power;
twosamplefreq test=fisher
groupproportions= (.63 .46)
alpha= .05
groupns= (49, 13) /* <- adjust the size of group 2 until calculated power = 0.8 */
power= .;
run;
hth
My groups are the event, the 49 is no for the event and 13 is yes for the event. That is why I took it out of the 62. Is this not correct?
So, you have a proportion of 49/62 events in your (single) sample. So you must be looking for the power of a one sample frequency test?
Significance of what? That group 1 is greater than group 2? Or what?
proc power provides a calculation of the power of the exact binomial test for the proportion of events in a single sample. To calculate the power of detecting a difference in the number of events and non-events within a sample of size 62, when the event probability is 0.21 (= 13/62), you can do:
proc power;
onesamplefreq
test = exact
ntotal = 62
nullproportion = 0.5
alpha = 0.05
proportion = 0.21 /* = 13 / 62 */
power = .;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.