mnu
mnu

Reputation: 3

How to write Do loop in SAS to use the proc power?

I am trying to produce the sample size for various value of power? I can do it for one specific value of power (say 0.90). I plan to write do loop over different power values (0.8 to 0.95 increased by 0.01). Also save the data that will have, alpha, power, p1, p2 and sample size.

I can do it only for one power value as showed below.

  proc power;
     twosamplefreq test=pchi
       groupproportions = (0.16 0.11 )
       sides=1
       nullproportiondiff=0
       alpha = 0.0249
       power = 0.90
       ntotal = .
       ;
    run;

Upvotes: 0

Views: 48

Answers (1)

Stu Sztukowski
Stu Sztukowski

Reputation: 12934

You can actually do this in PROC POWER directly by saying power=0.8 to 0.95 by 0.01.

PROC POWER does not output datasets natively, but you can output the underlying table that drives the output. If you turn ods trace on, you can see that the table's name is called output. We can select this and output it as a table named power:

proc power;
     twosamplefreq test=pchi
       groupproportions = (0.16 0.11 )
       sides=1
       nullproportiondiff=0
       alpha = 0.0249
       power = 0.8 to 0.95 by 0.01
       ntotal = .
       ;

     ods output output=power;
 run;

enter image description here

Upvotes: 1

Related Questions