Statements  Explanation 

use "C:\NHANES\DATA\analysis_data.dta", clear 
Use the use command to load the Stataformat dataset. Use the clear option to replace any data in memory. 
svyset [w=wtsaf4yr], psu(sdmvpsu) strata(sdmvstra) vce(linearized)

Use the svyset command to declare the survey design for the dataset. Specify the psu variable sdmvpsu. Use the [w=] option to account for the unequal probability of sampling and nonresponse. In this example, the MEC fasting weight for four years of data (wtsaf4yr) is used because this analysis uses four years of data and serum triglyercide measurements obtained from persons who fasted nine hours and were examined in the morning at the MEC. Use the strata ( ) option to specify the stratum identifier (sdmvstra). Use the vce( ) option to specify the variance estimation method (linearized) for Taylor linearization. This is the default method if the option is not specified. 
gen lnlbxtr=ln(lbxtr) 
Use the gen command to generate a new variable which is the log transformed triglycerides variable (lnlbxtr). 
svy:mean lnlbxtr, subpop(if ridageyr >=20 & ridageyr<.)

Use the svy : mean command with the fasting triglycerides log transformed variable (lnlbxtr) to estimate geometric mean triglycerides value for people 20 years and older. 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. This example uses an if statement to define the subpopulation based on the age variable's (ridageyr) value. Another option is to create a dichotomous variable where the subpopulation of interest is assigned a value of 1, and everyone else is assigned a value of 0. 
ereturn display, eform(geo_mean) 
Use ereturn display, eform( ) to display the geometric mean in the original units of triglyceride (i.e., the exponentiated coefficients) (geo_mean), standard error, and confidence interval. 
svy: mean lnlbxtr, subpop(if ridageyr >=20
& ridageyr<.) over(riagendr)

Use the svy : mean command with the fasting triglycerides log transformed variable (lnlbxtr) to estimate geometric mean triglycerides value for people 20 years and older. 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. This example uses an if statement to define the subpopulation based on the age variable's (ridageyr) value. Another option is to create a dichotomous variable where the subpopulation of interest is assigned a value of 1, and everyone else is assigned a value of 0. Use the over option to get stratified results. This example produces estimates by gender. 
ereturn display, eform(geo_mean)  Use ereturn display, eform( ) to display the geometric mean in the original units of triglyceride (i.e., the exponentiated coefficients) (geo_mean), standard error, and confidence interval. 
svy: mean lnlbxtr, subpop(if ridageyr >=20 & ridageyr<.) over(riagendr age1)

Use the svy : mean command with the log transformed triglycerides variable (log_lbxtr) to estimate mean triglyceride values by gender (riagendr) and age (age1). 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 get stratified results. This example produces estimates by gender and age. 
ereturn display, eform(geo_mean)  Use ereturn display, eform( ) to display the geometric mean in the original units of triglyceride (i.e., the exponentiated coefficients) (geo_mean), standard error, and confidence interval. 