FOCUS AREAS

SAS/STAT Software Examples

Estimating Geometric Means Using Data from a Complex Survey Sampling Design


Contents | SAS Program | PDF


data example;
   input plant shift clostridium wgt;
   datalines;
 1     1       60    10.3676
 1     1      129    11.4145
 1     1        5    10.3055
 1     2      159    10.3626
 1     2       38    11.1399
 1     2       72    10.7285
 2     1     6335    11.2469
 2     1      605    10.7137
 2     1        1    11.4907
 2     2       39    10.3051
 2     2        2    11.6742
 3     1       68    10.9728
 3     1       13    10.7298
 3     1        1    11.6157
 3     2        2    11.5689
 3     2       23    10.9979
 3     2        4    11.1901
 3     2        8    11.2892
 3     2        7    11.0138
 3     2       97    11.0352
 4     1       27    10.4380
 4     1       12    10.0849
 4     1       46    10.2071
 4     2        1    11.6617
 4     2        8    10.9302
 4     2       52    11.5752
 5     1        5    11.8787
 5     1        3    11.0835
 5     1       70    10.8487
 5     1       19    10.9051
 5     2       45    11.8979
 5     2        4    10.2815
 5     2        7    11.4535
 5     2        9    11.4642
 6     1        3    10.0098
 6     1       39    11.3282
 6     1       28    11.9952
 6     1       17    11.6234
 6     2       99    11.4800
 6     2        7    11.0777
 6     2        2    10.5838
 6     2      113    11.8282
 7     1     1607    10.7748
 7     1        2    10.7916
 7     1      453    11.1947
 7     1       27    10.3075
 7     2      722    11.7822
 7     2       12    10.9610
 7     2        9    10.2489
 7     2     5132    10.3248
 7     2        6    10.8066
 7     2      429    11.2076
 7     2        1    10.9459
 8     1       19    10.5508
 8     1        6    10.4444
 8     1       14    11.0870
 8     1       19    10.8481
 8     2      224    11.6004
 8     2      123    11.6580
 9     1        5    10.5234
 9     1        6    10.7325
 9     1        5    11.5270
 9     1       10    11.5454
 9     1     1276    10.4534
 9     2       60    11.7450
 9     2      439    11.7261
 9     2       23    10.6701
 9     2      258    11.4476
 9     2       21    11.6092
10     1       14    10.4388
10     1      103    10.0208
10     1      283    11.5510
10     2        5    10.0402
10     2       53    10.1998
10     2        1    10.9850
10     2        1    10.9713
10     2        1    10.8564
10     2      988    10.7164
10     2       91    10.6087
10     2       30    11.0570
10     2        2    11.3370
11     1        4    11.2579
11     1      545    10.9230
11     1       12    11.2702
11     1      182    10.2092
11     1        2    11.0256
11     1       11    11.9437
11     1      765    10.8006
11     2      212    10.0644
11     2        8    11.3593
11     2     1038    10.8533
11     2      284    10.7283
11     2       89    10.6535
12     1       28    11.5843
12     1       86    10.2384
12     1        1    11.4838
12     2        4    11.0882
12     2       41    11.0867
12     2       53    11.0240
12     2        3    10.3009
13     1      155    10.2052
13     1       39    11.7169
13     1      998    11.2657
13     2        9    11.5742
13     2        1    10.1637
13     2       36    10.5616
14     1       22    11.0577
14     1      236    11.9352
14     1      689    11.1176
14     1        1    10.1204
14     1       49    10.4860
14     1        1    11.9731
14     2     2119    11.6247
14     2     1499    10.8330
14     2      262    10.4739
14     2        6    11.9284
14     2       57    10.8997
15     1        8    11.6534
15     2        3    11.5217
15     2      168    10.7859
15     2        9    11.7750
15     2      214    10.1568
15     2        4    11.8919
15     2       10    11.3902
15     2        2    10.2044
15     2       94    11.3161
16     1       40    11.6117
16     1        1    11.6934
16     2       41    10.9345
16     2       12    10.2290
16     2       54    11.6304
16     2        2    10.9012
17     1      522    10.6988
17     1       91    11.0200
17     1        7    11.8308
17     1      651    11.4421
17     1        2    10.9235
17     1        9    11.6905
17     1       94    10.2847
17     2       13    10.1499
17     2        1    10.2152
17     2        1    11.5361
17     2      518    11.4654
17     2      373    11.3477
17     2       16    11.5300
18     1      385    10.8121
18     1      344    11.7429
18     1      405    11.3669
18     2        7    11.6716
18     2        1    11.5920
18     2      140    10.0531
18     2       23    11.9768
18     2       51    10.4346
19     1      699    11.7445
19     2        1    11.3561
19     2        1    11.8978
20     1        2    10.0703
20     1        3    10.6160
20     1       10    11.8972
20     1       18    11.0392
20     1      169    10.5357
20     2       39    10.7831
20     2      335    10.8822
20     2      313    10.6158
20     2     1017    10.7235
20     2       23    11.1932
20     2        3    11.1999
20     2        1    11.6239   
;
run;

data example;
   set example;
   logClostridium = log(clostridium);
run;

proc surveymeans data=example;
   weight wgt;
   strata plant;
   cluster shift;
   var logClostridium;
   ods output statistics = estimates;
run;

data estimates;
   set estimates;
   Mean = exp(Mean);
   StdErr  = sqrt((Mean**2)*(StdErr**2));
   LowerCLMean = exp(LowerCLMean);
   UpperCLMean = exp(UpperCLMean);
   VarName = 'Clostridium';
   label Mean='Geometric Mean' 
         StdErr='Standard Error'
         LowerCLMean='Lower 95% Confidence Limit'
         UpperCLMean='Upper 95% Confidence Limit';
run;             

proc print data=estimates label noobs;
run;

proc surveymeans data=example allgeo;
   weight wgt;
   strata plant;
   cluster shift;
   var Clostridium;
run;