Introduction to Power and Sample Size Analysis

Customized Power Formulas (DATA Step)

If you want to perform a power computation for an analysis that is not currently supported directly in SAS/STAT tools, and you have a power formula, then you can program the formula in the DATA step.

For purposes of illustration, here is the power formula in the section Computing Power and Sample Size implemented in the DATA step to compute power for the t test example:

data tpow;
   do meandiff = 5, 6;
      do stddev = 12, 18;
         do alpha = 0.05, 0.1;
            do ntotal = 100, 200;
               ncp = ntotal * 0.5 * 0.5 * meandiff**2 / stddev**2;
               critval = finv(1-alpha, 1, ntotal-2, 0);
               power = sdf('f', critval, 1, ntotal-2, ncp);
               output;
            end;
         end;
      end;
   end;
run;
proc print data=tpow;
run;

The output is shown in Figure 5.

Figure 5: Customized Power Formula (DATA Step)

Obsmeandiffstddevalphantotalncpcritvalpower
15120.051004.34033.938110.54102
25120.052008.68063.888850.83447
35120.101004.34032.757430.66434
45120.102008.68062.731040.90171
55180.051001.92903.938110.27981
65180.052003.85803.888850.49793
75180.101001.92902.757430.39654
85180.102003.85802.731040.62287
96120.051006.25003.938110.69689
106120.0520012.50003.888850.94043
116120.101006.25002.757430.79895
126120.1020012.50002.731040.96985
136180.051002.77783.938110.37857
146180.052005.55563.888850.65012
156180.101002.77782.757430.50459
166180.102005.55562.731040.75935


Last updated: October 28, 2020