Simple random sampling
page 29 Table 2.4 Estimates from a simple random sample drawn without replacement (n = 8); the Province’91 population.
data page29; input id cluster ue91 lab91; fpc = 32; wt = 4; strata = 1; cards; 1 1 4123 33786 2 4 760 5919 3 5 721 4930 4 15 142 675 5 18 187 1448 6 26 331 2543 7 30 127 1084 8 31 219 1330 ; run;
The code below gets the total and the standard deviation of the total for the variable ue91 as shown in the first line of the table. You cannot get both the total and the median in the same proc descript. The two setenv statements are optional; they only control the appearance of the output. The print statement tells SUDAAN what to include in the output. The print statement will override any of the statistics listed on the proc descript statement. In other words, if you request the mean on the proc descript statement and do not include mean on the print statement, the mean will not be displayed in the output.
proc descript data = page29 filetype = sas design = wor ; weight wt; nest strata; totcnt fpc; var ue91 ; print nsum total setotal mean semean deffmean ; setenv colwidth = 15; setenv decwidth = 3; run;
Number of observations read : 8 Weighted count : 32 Denominator degrees of freedom : 7 Variance Estimation Method: Taylor Series (WOR) by: Variable, One. ----------------------------------------------------- | | | | Variable | | One | | | 1 | ----------------------------------------------------- | | | | | UE91 | Sample Size | 8 | | | Total | 26440.00 | | | SE Total | 13282.26 | | | Mean | 826.25 | | | SE Mean | 415.07 | | | DEFF Mean #4 | 0.75 | -----------------------------------------------------
The code below produces the correct ratio estimate, except that you have to move the decimal over two places.
proc ratio data = page29 filetype = sas design = wor; weight wt; nest strata; totcnt fpc; numer ue91; denom lab91; run;
Number of observations read : 8 Weighted count : 32 Denominator degrees of freedom : 7 Variance Estimation Method: Taylor Series (WOR) by: Variable, One. --------------------------------------------------- | | | | Variable | | One | | | 1 | --------------------------------------------------- | | | | | UE91/LAB91 | Sample Size | 8 | | | Weighted Size | 32.00 | | | Weighted X-Sum | 206860.00 | | | Weighted Y-Sum | 26440.00 | | | Ratio Est. | 0.13 | | | SE Ratio | 0.00 | ---------------------------------------------------
The code below produces that median shown on the third line of the table. This, and most of the other estimates of medians, is slightly different from what is shown in the text. We suspect that this difference is the result of slightly different algorithms used by the different packages (PC Carp was used to generate the estimates given in the text).
proc descript data = page29 filetype = sas design = wor ; weight wt; nest strata; totcnt fpc; var ue91 ; percentile / median; setenv colwidth = 10; setenv decwidth = 3; run;
Number of observations read : 8 Weighted count : 32 Denominator degrees of freedom : 7 Variance Estimation Method: Taylor Series (WOR) by: Variable, One, Percentiles. for: Variable = UE91. ----------------------------------------------------------------------------------- One Sample Weighted Lower 95% Upper 95% Percentiles Size Size Quantile Limit Limit ----------------------------------------------------------------------------------- 1 50.00 8 32.00 219.00 135.74 737.27 ----------------------------------------------------------------------------------- --------------------------------- One SE Percentiles Quantile --------------------------------- 1 50.00 127.19 ---------------------------------
Systematic sampling
page 46 Table 2.6 Estimates from a systematic sample drawn from the Province’91 population using implicit stratification.
NOTE: The standard error of the total is different from that shown in the text (the text shows 11802). However, we get the 13627 in each of the statistical packages in which we have tried to recreate this example.
data page44 ; input id str clu wt ue91 lab91 smplrat; fpc = 32; cards; 1 1 1 4 4123 33786 .25 2 1 5 4 721 4930 .25 3 2 9 4 194 2069 .25 4 2 13 4 129 927 .25 5 2 17 4 239 2144 .25 6 2 21 4 61 573 .25 7 2 25 4 262 1737 .25 8 2 29 4 166 1615 .25 ; run; proc descript data = page44 filetype = sas design = wr totals; weight wt; nest str; var ue91; run;
Number of observations read : 8 Weighted count : 32 Denominator degrees of freedom : 6 Variance Estimation Method: Taylor Series (WR) by: Variable, One. ----------------------------------------------------- | | | | Variable | | One | | | 1 | ----------------------------------------------------- | | | | | UE91 | Sample Size | 8 | | | Weighted Size | 32.00 | | | Total | 23580.00 | | | SE Total | 13627.19 | | | Mean | 736.88 | | | SE Mean | 425.85 | -----------------------------------------------------
proc ratio data = page44 filetype = sas design = wr; weight wt; nest str; numer ue91; denom lab91; setenv colwidth = 15; setenv decwidth = 5; run;
Number of observations read : 8 Weighted count : 32 Denominator degrees of freedom : 6 Variance Estimation Method: Taylor Series (WR) by: Variable, One. -------------------------------------------------------- | | | | Variable | | One | | | 1 | -------------------------------------------------------- | | | | | UE91/LAB91 | Sample Size | 8.00000 | | | Weighted Size | 32.00000 | | | Weighted X-Sum | 191124.00000 | | | Weighted Y-Sum | 23580.00000 | | | Ratio Est. | 0.12338 | | | SE Ratio | 0.00385 | --------------------------------------------------------
proc descript data = page44 filetype = sas design = strwr; weight wt; nest str; var ue91; percentile / median; run;
Number of observations read : 8 Weighted count : 32 Denominator degrees of freedom : 6 Variance Estimation Method: Taylor Series (STRWR) by: Variable, One, Percentiles. for: Variable = UE91. ----------------------------------------------------------------------------------- One Sample Weighted Lower 95% Upper 95% Percentiles Size Size Quantile Limit Limit ----------------------------------------------------------------------------------- 1 50.00 8 32.00 194.00 83.82 248.65 ----------------------------------------------------------------------------------- --------------------------------- One SE Percentiles Quantile --------------------------------- 1 50.00 33.68 ---------------------------------
page 60 Table 2.8 Estimates under a PPSSYS design (n = 8); the Province’91 population.
NOTE: The certainty PSU (the first line of the data) was entered twice and the weight was changed from 1 to .5 for each observation. This is necessary because you need to have two observations in each strata.
data page60; input id str clu wt hou85 ue91 lab91; fpc = 32; cards; 1 2 1 0.5 26881 4123 33786 2 2 1 0.5 26881 4123 33786 3 1 10 1.004 9230 1623 13727 4 1 4 1.893 4896 760 5919 5 1 7 2.173 4264 767 5823 6 1 32 2.971 3119 568 4011 7 1 26 4.762 1946 331 2543 8 1 18 6.335 1463 187 1448 9 1 13 13.730 675 129 927 ; run; proc sort data = page60; by str; run; proc descript data = page60 filetype = sas design = wr total; weight wt; nest str; var ue91; run;
Number of observations read : 9 Weighted count : 34 Denominator degrees of freedom : 7 Variance Estimation Method: Taylor Series (WR) by: Variable, One. ----------------------------------------------------- | | | | Variable | | One | | | 1 | ----------------------------------------------------- | | | | | UE91 | Sample Size | 9 | | | Weighted Size | 33.87 | | | Total | 15077.43 | | | SE Total | 521.12 | | | Mean | 445.18 | | | SE Mean | 150.47 | -----------------------------------------------------
NOTE: Use the setenv statement to set the decwidth to 5 to show the decimal to five places so that you can see that the standard error is correct. If you do not use the setenv decwidth = 5 statement, it appears that the standard error is .00.
proc ratio data = page60 filetype = sas design = wr; weight wt; nest str; numer ue91; denom lab91; setenv colwidth = 20; setenv decwidth = 5; run;
Number of observations read : 9 Weighted count : 34 Denominator degrees of freedom : 7 Variance Estimation Method: Taylor Series (WR) by: Variable, One. ------------------------------------------------------------- | | | | Variable | | One | | | 1 | ------------------------------------------------------------- | | | | | UE91/LAB91 | Sample Size | 9.00000 | | | Weighted Size | 33.86800 | | | Weighted X-Sum | 117353.19100 | | | Weighted Y-Sum | 15077.42800 | | | Ratio Est. | 0.12848 | | | SE Ratio | 0.00222 | -------------------------------------------------------------
proc descript data = page60 filetype = sas design = wr; weight wt; nest str; var ue91; percentile / median; run;
Number of observations read : 9 Weighted count : 34 Denominator degrees of freedom : 7 Variance Estimation Method: Taylor Series (WR) by: Variable, One, Percentiles. for: Variable = UE91. ----------------------------------------------------------------------------------- One Sample Weighted Lower 95% Upper 95% Percentiles Size Size Quantile Limit Limit ----------------------------------------------------------------------------------- 1 50.00 9 33.87 158.33 . 527.82 ----------------------------------------------------------------------------------- --------------------------------- One SE Percentiles Quantile --------------------------------- 1 50.00 . ---------------------------------
The code below produces the graph on page 63. This is SAS code and not SUDAAN code.
goption reset = all; symbol i=r v=circle; proc gplot data = page60; plot ue91*hou85; run; quit;