Task 4: How to Recode Variables Based on Alternate Definitions

This task reviews how to recode variables so they are appropriate for your analytic needs and how to check your derived variables.

 

Step 1 Recode based on alternate definitions

Recoding is an important step for preparing an analytical dataset.  In this step, you will view programs that recode variables using different techniques for each of the scenarios listed on the Clean & Recode Data: Key Concepts about Recoding Variables in NHANES I page. In the summary table below, each statement required for recoding is listed on the left with explanations on the right. 

 

Program to Recode as Necessary Based on Alternate Definitions

Statements Explanation

data demo3_nh1;

      set demo2_nh1;

Use the data and set statements to refer to your analytic dataset.

if (20 <=n1bm0101 <= 39) then  age3cat=1 ;
else if ( 40 <= n1bm0101<= 59 ) then age3cat= 2 ;
else if n1bm0101>= 60 then age3cat= 3 ;