Generate Means in Stata

Statements Explanation

use
"C:\nhanes\data\analysis_data.dta",
clear  

Use the use command to load the Stata-format dataset. Use the clear option to replace any data in memory.

svyset sdmvpsu [pweight=wtmec4yr], strata(sdmvstra) vce(linearized)

 

Use the svyset command to declare the survey design for the dataset. Specify the psu variable sdmvpsu. Use the [pweight=] option to account for the unequal probability of sampling and non-response.  In this example, the MEC weight for four years of data (wtmec4yr) is used. Use the strata( ) option to specify the stratum identifier (sdmvstra). Use the vce( ) option to specify the variance estimation method  (linearized) for Taylor linearization.

quietly svy, subpop(if ridageyr >=20  & ridageyr <.) vce(linearized): mean lbxtc

estat size, obs

Use the prefix quietly before the svy command to suppress terminal output. Use the svy: mean command with the total cholesterol variable (lbxtc) to estimate mean total cholesterol. Use the subpop( ) option to select a subpopulation for analysis, rather than select the study population in the Stata program while preparing the data file. Use the estate size post estimation command to display subpopulation sizes.

quietly svy, subpop(if ridageyr >=20 & ridageyr <.) vce(linearized): mean lbxtc, over(riagendr)

estat size, obs

 
Use the prefix quietly before the svy command to suppress terminal output. Use the svy: mean command with the total cholesterol variable (lbxtc) to estimate mean total cholesterol. Use the subpop( ) option to select a subpopulation for analysis, rather than select the study population in the Stata program while preparing the data file. Use the over( ) option to specify subgroup tabulations for estimates requested.  In this example, gender (riagendr) is of interest. Use the estate size post estimation command to display subpopulation sizes.

quietly svy, subpop(if ridageyr >=20 & ridageyr <.) vce(linearized): mean lbxtc, over(age)

estat size, obs

Use the prefix quietly before the svy command to suppress terminal output. Use the svy: mean command with the total cholesterol variable (lbxtc) to estimate mean total cholesterol. Use the subpop( ) option to select a subpopulation for analysis, rather than select the study population in the Stata program while preparing the data file. Use the over( ) option to specify subgroup cross-tabulations for estimates requested.  In this example, race-ethnicity (race) is of interest. Use the estate size post estimation command to display subpopulation sizes.

quietly svy, subpop(if ridageyr >=20 & ridageyr <.) vce(linearized): mean lbxtc, over(riagendr age)

estat size, obs

Use the prefix quietly before the svy command to suppress terminal output.Use the svy: mean command with the total cholesterol variable (lbxtc) to estimate mean total cholesterol. Use the subpop( ) option to select a subpopulation for analysis, rather than select the study population in the Stata program while preparing the data file. Use the over( ) option to specify subgroup cross-tabulations for estimates requested.  In this example, gender (riagendr), and race-ethnicity (race) are of interest. Use the estate size post estimation command to display subpopulation sizes.