The instructions below will show you how to recode variables. You can use recoding to produce different values or codes for a variable. Recoding can be done in one of two ways:
In this guide, we will concentrate on recoding into a different variable, for which there are 3 main types of recoding:
We will use an example of each type in order to demonstrate how to recode variables in SPSS Statistics.
Example: The data given below represents runs scored by 5 batsmen in a national-level match. Recode the data so that the batsmen are rank ordered by their number of runs, with the batsman with the highest runs given a code of "1" and the batsman with the lowest runs given a "5".
Number of runs by batsmen | |||||
Batsmen | 1 | 2 | 3 | 4 | 5 |
Runs | 86 | 120 | 56 | 10 | 18 |
Enter the data in the SPSS Statistics Data Editor and name the variable "Runs".
Remember that each individual's results go on a separate line (row) in SPSS Statistics.
Published with written permission from SPSS Statistics, IBM Corporation.
Click on Transform > Recode Into Different Variables... in the top menu.
Published with written permission from SPSS Statistics, IBM Corporation.
You need to highlight the Runs variable in the left-hand box by clicking on it and then click the button to move it across to the Numeric Variable -> Output Variable: box.
Published with written permission from SPSS Statistics, IBM Corporation.
In the -Output Variable- area show below, give the new variable you are about to create a name and label. In this example, we have named the new variable "Ranked-Runs" and the label as "Ranked Runs" (see the ).
Published with written permission from SPSS Statistics, IBM Corporation.
Click the button.
You should now see that the Numeric Variable -> Output Variable: box has now changed to reflect these changes (see the ).
Published with written permission from SPSS Statistics, IBM Corporation.
Click the button.
Enter the first score (120) into the Value: box within the -Old Value- area, and set the new code of "1" into Value: box within the -New Value- area.
Click the button.
Repeat for all other values, such that you are presented with the following screen:
Published with written permission from SPSS Statistics, IBM Corporation.
You will have returned to the previous screen and will now have to click the button. This will take you to the Data View Editor, which will now show that you have created a new variable that is based on recoding your existing variable:
Published with written permission from SPSS Statistics, IBM Corporation.