Task 1c: How to Format and Label NHANES Variables in Stata

Here are the steps to formatting and labeling NHANES variables :


Step 1: Define value labels

Value labels give a verbal description of the integer values of a variable and can make it more user-friendly. The generic form of the label define command is:

Label define label_name var_value


Label define yesno 1  Yes  2  No
Label define age 1 "Age 20-39" 2 "Age 40-59" 3 "Age 60+"
Label define race 1 "NH white" 2 "NH black" 3 "Mexican American" 4 "Other race/ethn"


warning iconWARNING

Don't forget to put double quotation marks around text with embedded blanks.


Step 2: Associate labels to variables

After you have defined value labels, you can associate them to selected variables using the label values command. The generic form of this command is:

Label values label_name var_name

Label values age age


Step 3: Apply labels to variables

Finally, label selected variables using the label variable command. User-defined labels should always be surrounded by double quotation marks. The generic form of the command is:

Label variable var_name var_text

Label variable age "Age in years"




close window icon Close Window