Last modified on 29 June 2010, at 03:06

Using SPSS and PASW/Recoding Variables

Recoding variables is useful tool in SPSS for when you want to change the codes for categories of a variable or when you have too many variable options (there are other times you may want to use it as well). Recoding variables allows you to modify the existing numbers assigned to variable values. There aren't really right or wrong ways to recode variables. However, recoding variables is often done for one of two reason: (1) to facilitate statistical calculations; (2) to combine or “collapse” categories when the number of responses in one category are too small for statistical analysis. A time when this is often helpful is when you are analyzing age. Instead of having ages range from 1-100 and having 100 options, you could recode the variable into categories such as 29 and under, 30-60, and 61+. This transforms age from a ratio variable into an ordinal variable, which may be useful in certain situations. When recoding variables, it is generally a good idea to first write down all of the categories of your variable on a piece of paper. Then, next to each category in the existing variable, write the code to which you want to recode it, as illustrated in the table below using a variable measuring frequency of religious attendance:

Old Codes New Codes
0=never 1=never to infrequently
1=less than once a year 1=never to infrequently
2=about once or twice a year 1=never to infrequently
3= several times a year 1=never to infrequently
4=about once a month 2=relatively frequently
5=two to three times a month 2=relatively frequently
6=nearly every week 2=relatively frequently
7=every week 2=relatively frequently
8= several times a week 2=relatively frequently
9=no answer 9=no answer

Writing this out is not a necessary step but does make recoding easier.

To actually perform the recode, click on the “Transform” menu at the top of data editor window:

09recodingvariables01.png

Click on “Recode into Different Variables.” Most of the time you should recode into different variables as doing so does not destroy the values of the existing variable. About the only time you would use the “Recode into Same Variable” command is when you are fixing the labels of an existing variable that were somehow messed up.

09recodingvariables02.png

You will now see the “Recode into Different Variables” window. You can choose variables from the list on the left and insert them into the box into the “Numeric Variable → Output Variable” box. Do this by selecting the variable and then clicking on the arrow button:

In the example above, the variable "attend" is selected and moved to the recode window.

Now type the new variable name label in the “Output Variable” “Name” and “Label” box. People have different preferences for how recoded variables are indicated. One common one is to add an “x” or “z” to the end of the original variable (e.g., attendx). Once you've added the name and label, click Change. This last part is very important as you cannot recode the variable until you select “Change.”

09recodingvariables04.png

To enter the old and new values you laid out in the table above, click “Old and New Values.” You'll get the following window:

09recodingvariables05.png

Using the handmade list we previously made, convert the old values into new values. Old Values are entered on the left, New Values are entered on the right. Click “Add” after you enter the old and new values for each variable to add them to the “Old → New” list. As you can see for variables 0 through 3 they have been recoded as “1.” Values 4 through 8 have been recoded as “2.” This can also be done by selecting the radio button next to “Range” and entering a range of values simultaneously.

When you are finished, click “continue.” This will bring you back to the variable window, where you can click “OK.”

You're not quite finished. You should return to the Data Editor window, Variable View. At the very bottom of your variable list you'll find your newly recoded variable. It's not a bad idea to drag the new variable next to the old one. You should also immediately edit the Value Labels to reflect the newly recoded values lest you forget what they are:

09recodingvariables06.png

Click “OK” and you’re done.

Chapter contributed by Megan Hauf.