Introduction to SPSS
7. Part V: Modifying your data
7.2. Recode an existing variable into a new variable
Now that we have our new variable BMI, we want to recode it into a new variable, bmicat, where the BMI values are categorised into underweight (BMI<18.5), normal weight (BMI >=18.5 and <25), overweight (BMI >=25 and <30), and obese (BMI>=30).
Here is the code to write in your syntax:
recode bmi (sysmis=sysmis) (lowest thru 18.499999=1) (18.5 thru 24.99999=2) (25.0 thru 29.99999=3)
(30 thru Highest=4) into bmicat.
execute.
The recode command is followed by the variable name (bmi), then we put in brackets the value ranges for each category, and give them a label (1, 2, 3, and 4 for the four categories). We also tell SPSS that any data that were missing (sysmis) we want to be missing in our new recoded variable. We are recoding the bmi variable INTO a new variable, bmicat.
If we didn’t include the “into bmicat” at the end of the syntax, we would recode the original bmi variable and would lose the individual BMI values and replace them with categories. I like to keep my original variables, so tend to use the INTO option to recode into a new variable.