4.4 Stata preparation

In Stata, we need to enter the following code to import the CSV file data:

import delimited [Path]/CLSARealExample.csv

To specify the sampling design, we define the stratum variables as WGHTS_GEOSTRAT_TRM and declare the survey design. Similar to the R program, we assume that strata with a single unit have no contribution to the variance estimation, so we put “certainty” in “singleunit().”

generate StraVar = GEOSTRAT_TRM 
svyset entity_id, strata(StraVar) weight(WGHTS_INFLATION_TRM) vce(linearized) 
                  singleunit(certainty)  

The option “singleunit(certainty)” means the program will ignore the strata with single observations during variance calculation. Again, this option may not be the best one as it can underestimate the uncertainty.