Previous Page | Next Page

Introduction to Power and Sample Size Analysis

Customized Power Formulas (DATA Step)

If you want to perform a power compuation 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 19.6.

Figure 19.6 Customized Power Formula (DATA Step)
Obs meandiff stddev alpha ntotal ncp critval power
1 5 12 0.05 100 4.3403 3.93811 0.54102
2 5 12 0.05 200 8.6806 3.88885 0.83447
3 5 12 0.10 100 4.3403 2.75743 0.66434
4 5 12 0.10 200 8.6806 2.73104 0.90171
5 5 18 0.05 100 1.9290 3.93811 0.27981
6 5 18 0.05 200 3.8580 3.88885 0.49793
7 5 18 0.10 100 1.9290 2.75743 0.39654
8 5 18 0.10 200 3.8580 2.73104 0.62287
9 6 12 0.05 100 6.2500 3.93811 0.69689
10 6 12 0.05 200 12.5000 3.88885 0.94043
11 6 12 0.10 100 6.2500 2.75743 0.79895
12 6 12 0.10 200 12.5000 2.73104 0.96985
13 6 18 0.05 100 2.7778 3.93811 0.37857
14 6 18 0.05 200 5.5556 3.88885 0.65012
15 6 18 0.10 100 2.7778 2.75743 0.50459
16 6 18 0.10 200 5.5556 2.73104 0.75935

Previous Page | Next Page | Top of Page