This example is taken from Levy and Lemeshow’s Sampling of Populations.
page 198 ratio estimation This example uses the tab7pt1 data set. Note that there may be a typo in the text for the weighted X-sum and the weighted Y-sum.
proc ratio data = tab7pt1 filetype = sas design=strwor; totcnt totcnt; weight wt1; nest _one_; numer pharmexp; denom totmedex; setenv colwidth = 1; setenv decwidth = 4; run;
Number of observations read : 7 Weighted count : 8 Denominator degrees of freedom : 6 Variance Estimation Method: Taylor Series (STRWOR) by: Variable, One. --------------------------------------------------- | | | | Variable | | One | | | 1 | --------------------------------------------------- | | | | | PHARMEXP/TOTME- | Sample Size | 7 | | DEX | Weighted Size | 8.00 | | | Weighted X-Sum | 3222857.14 | | | Weighted Y-Sum | 1028571.43 | | | Ratio Est. | 0.32 | | | SE Ratio | 0.00 | ---------------------------------------------------
This example is taken from Lehtonen and Pahkinen’s Practical Methods for Design and Analysis of Complex Surveys.
The code below gives the numbers that are shown in the calculations on page 102.
data page102; input id str clu wt ue91 hou85 gwt adjwt smplrat; fpc = 32; datalines; 1 1 1 4 4123 26881 .5562 2.2248 .25 2 1 4 4 760 4896 .5562 2.2248 .25 3 1 5 4 721 3730 .5562 2.2248 .25 4 1 15 4 142 556 .5562 2.2248 .25 5 1 18 4 187 1463 .5562 2.2248 .25 6 1 26 4 331 1946 .5562 2.2248 .25 7 1 30 4 127 834 .5562 2.2248 .25 8 1 31 4 219 932 .5562 2.2248 .25 ; run;
You can get the necessary numbers either of two ways: You can use proc descript and get the totals for both variables and do the division on your own, or you can use proc ratio, as shown below. NOTE: 6610/41238 = .16028905, which is the correct answer.
proc descript data = page102 filetype = sas design = wor; weight wt; nest _one_; totcnt fpc; var ue91 hou85; subgroup str; levels 1; postvar str; postwgt 8; run;
Number of observations read : 8 Weighted count : 32 Denominator degrees of freedom : 7 Variance Estimation Method: Taylor Series (WOR) Post-stratified estimates by: Variable, STR. -------------------------------------------------------------------- | | | | Variable | | STR | | | Total | 1 | -------------------------------------------------------------------- | | | | | | UE91 | Sample Size | 8 | 8 | | | Weighted Size | 8.00 | 8.00 | | | Total | 6610.00 | 6610.00 | | | Mean | 826.25 | 826.25 | | | SE Mean | 415.07 | 415.07 | -------------------------------------------------------------------- | | | | | | HOU85 | Sample Size | 8 | 8 | | | Weighted Size | 8.00 | 8.00 | | | Total | 41238.00 | 41238.00 | | | Mean | 5154.75 | 5154.75 | | | SE Mean | 2728.08 | 2728.08 | --------------------------------------------------------------------
The goal is to get the .1603 shown in the upper middle of page 102. You need this ratio estimate so that you can multiply it by the population total of the auxiliary variable to calculate the ratio estimate for the total of the variable of interest.
proc ratio data = page102 filetype = sas design = wor; weight wt; nest _one_; totcnt fpc; numer ue91; denom hou85; subgroup str; levels 1; postvar str; postwgt 8; setenv decwidth = 4; run;
Number of observations read : 8 Weighted count : 32 Denominator degrees of freedom : 7 Variance Estimation Method: Taylor Series (WOR) Post-stratified estimates by: Variable, STR. ---------------------------------------------------------------- | | | | Variable | | STR | | | Total | 1 | ---------------------------------------------------------------- | | | | | | UE91/HOU85 | Sample Size | 8.0000 | 8.0000 | | | Weighted Size | 8.0000 | 8.0000 | | | Weighted X-Sum | 41238.0000 | 41238.0000 | | | Weighted Y-Sum | 6610.0000 | 6610.0000 | | | Ratio Est. | 0.1603 | 0.1603 | | | SE Ratio | 0.0055 | 0.0055 | ----------------------------------------------------------------