Stata Commands for Generating Age-Adjusted Means
Statements Explanations

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.

svy, subpop(if ridageyr >=20 & ridageyr <.): mean bmxbmi, stdize(age) stdweight(std_wgt) over(riagendr race)

 

 

 
Use the svy : mean command with the body mass index variable (bmxbmi) to estimate mean BMI. 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 stdize( ) and stdweight( ) options to yield standardized estimates of the mean. In the example, age is the standardizing variable as defined by the stdize( ) statement. The stdweight( ) option specifies the population proportions based on the 2000 Census estimates as defined by the variable std_wgt. Use the over( ) option to specify subgroup cross-tabulations for estimates requested. In this example, gender (riagendr), and race-ethnicity (race) are of interest.
Info iconIMPORTANT NOTE

To calculate the unadjusted prevalence, use the program code above, EXCEPT DO NOT USE the stdize and stdweight options.