Task 1a: How to Format and Label NHANES Variables in SAS
Here are the steps to formatting and labeling NHANES variables :
- Define custom formats
- Apply formats to variables
- Apply labels to variables
Step 1: Define custom formats
These user-defined formats used here include the:
- yesno format, which formats the 1 value as 'Yes' and the 2 value
as 'No';
- age format, which formats the 1 value as 'Age 20-39', the 2 value
as 'Age 40-59', and the 3 value as 'Age 60+'; and
- race format, which formats the 1 value as 'NH white' , the 2 value
as 'NH black' the 3 value as 'Mexican American', and the 4 value as 'Other
race/ethn'.
Use proc format with a value statement for each variable to assign
the format to the selected value.
Don't forget to put format names in single or double quotation marks.
When defining formats in SAS, do not forget to put format names in single
or double quotation marks. |
Step 2: Apply formats to variables
After you have assigned formats, you can apply them to
selected variables using the format statement in the data
step of your code. Please note that format names always come
directly after variable names and MUST end with a period.
Step 3: Apply labels to variables
Finally, label selected variables using a label statement.
User-defined labels should always be surrounded by single quotation marks.
Close Window