You are on page 1of 4

CHAPTER 17

BASIC TRANSFORMATIONS: RECODE


(Also: Categorize Variables)
The RECODE command allows the user to change the values assigned to an existing variable. It is
speedy, accurate and consistent means for applying new values to variables.
Uses of RECODE
1.

To use a continuous variable in a crosstabulation (here is an opportunity for you to use


SPSSWIN's Help facility to learn what is meant by the term "crosstabulation") it is necessary to
collapse ithe variables values into a set of discreet categories. For example, to be able to use
the variable "age" in a crosstabulation, you might create five age categories (e.g., 18-24, 25-34,
35-49, 50-64, and 65+) with the RECODE transformation. When we use recode to collapse the
values of a variable, inevitably some detail is lost. If we collapse responses of "Strongly Agree"
and "Agree" together, we lose the detail of what portion of respondents had a stronger level of
agreement.

2.

You have too few cases in a category or value and wish to combine them with another value. For
example, to lump miscellaneous values into one value to be labeled "other."

3.

In scale construction it may be necessary to change the values of a variable. For example, in a
set of questionnaires items, you might need to "reverse" the coding of some items so that a low
value on all items has the same conceptual meaning (e.g., "negative"). Typically, our goal is to
create a total score based upon a sum of scores from individual items. We use reverse coding so
that, for instance, a higher value will represent a more positive attitude for each of a series of
statements.
For instance, note that a value of "1" ("strongly agree") does not have the same conceptual
meaning for the three statements below. A "liberal" would be less likely to agree with Q. #1 or
Q.#3. Therefore, certain scales would need to be reversed so that a low (or high) numeric value
for each item has the same meaning. Below you would either recode #1 and #3 or recode #2. In
the recode of #1 and #3, low values indicate liberal views. In the recode of #2, high values
indicate a liberal position. The recoding would reassign values: a value of "1" would be recoded to
"5", a value of "2" would be recoded to "4", and so on.
1 = Strongly Agree

2 = Agree

3 = Unsure

4 = Disagree

5 = Strongly Disagree

A woman should not have the right to an abortion.

2.

Government regulations and requirements to protect the environment are worth the extra
cost added to the products and services the average person buys.

3.

Sexual relations between two adults of the same sex is wrong.

RECODE INTO SAME vs. DIFFERENT VARIABLES


When you choose RECODE you are presented with a choice of recoding into the same or different
variables. This is an important distinction.
RECODE INTO SAME VARIABLES
If you RECODE into the SAME variable(s), this means that the new values you will assign for the
variable(s) will overwrite the existing (original) values. If you save the file with this recode intact, you
permanently lose the original values for the variable(s). Recommendation: Do NOT recode into the
same variable.
RECODE INTO DIFFERENT VARIABLES

If you RECODE into DIFFERENT variable(s), this means that you create new variables which take the
new values you assign. If you save the file with the recode intact, you save the new variables along with
previously existing ones.
Opening the RECODE Dialog Box for RECODE INTO DIFFERENT VARIABLES
1.

From the menus, click on TRANSFORM RECODE RECODE INTO DIFFERENT


VARIABLES

2.

From the variable list click on a variable (or variables) you wish to recode.

3.

Then, click on the arrow (>) pushbutton. The variable name will appear in the Input variable -->
Output variable box (the selected variables box). If you wish to recode more than one variable
with the same codes, repeat the process until all variables to be recoded appear in the Input
variable --> Output variable box.
The variables might appear as follows:
v2 --> ?
v4 --> ?

4.

If you are only recoding one variable, it will be highlighted in the Input variable --> Output variable
box. You would then click on the Output Variable Name box. You must give the new variable a
name. Type in the name for the variable to be created. Standard SPSSWIN variable naming rules
apply. [If recoding a set of variables having the same values, also see step (13) below.]

5.

Once a variable name has been entered, click on the CHANGE pushbutton. When this is done,
the variable name will appear in the Input variable --> Output variable box. For example: v2 -->
v2a

6.

You can label the variable if desired by typing in a label. Alternatively, you can label the variable
and its values later by double clicking on the variable name in the Data Editor.

7.

Click on OLD AND NEW VALUES. This will open the RECODE INTO DIFFERENT VARIABLES:
OLD AND NEW VALUES Dialog Box.

8.

First, identify the "old" [existing] values you wish to recode. If it is one value, click on the VALUE
radio button and type in the number. If it is a set of values, click on RANGE and type in the
appropriate lowest and highest values. You can recode a system- or user-defined missing value
to a new value if desired. The "all other values" choice refers to all other remaining values that
have not been recoded. This is used last when recoding a set of values for a variable.
For example, for the "Age" variable, you could Recode the following "old" values to their
associated "new" values:
Old Values

New Value

Range: 18 through 24
Range: 25 through 34
Range: 35 through 49
Range: 50 through 65
All other values

1
2
3
4
5

NOTE: A "5" would be assigned to all values below 18 and above 65. [User-defined and systemdefined would also be assigned a value of "5". If you wanted missing values to remain treated as
missing, you would need to recode them to "sysmis" before assigning the value for "all other
values." In general, a recode of, for instance, "7 through highest" will include the user-defined
missing value (if the missing value code is higher than 7). Be careful !]

9.

Next, type in the New Value to which the old value(s) is/are to be recoded.

10.

After the New Value has been defined, click on the ADD pushbutton. In the Old --> New box the
recode statement will appear. For example: 18 thru 24 --> 1

11.

Repeat this process for each old value or range of values to be recoded. When you have
specified all recodes, click on the CONTINUE pushbutton.

12.

You are then returned to the RECODE INTO DIFFERENT VARIABLES Dialog Box. [Optional:
Click on PASTE to paste the Recode into the Syntax Window.] Return to RECODE INTO
DIFFERENT VARIABLES Dialog Box and click on OK. SPSSWIN Executes the Recode. The new
variable with its recoded values will appear in the appropriate column in the Data Editor.

13.

Sometimes one may have several variables to recode, each of which has the same set of values.
It is more efficient to recode the group of variables rather than each individual variable. For
example, observe the following questionnaire items (V31 - V34). As written, they are continuous
variables. They could be recoded into categorical variables (e.g., four values: 0 (zero), up to one
hour, 1-2 hours, and 2 or more hours).
Please estimate how many hours (rounded to the nearest quarter hour) you spend on each of the
following activities in a typical week:
Hours
(round to 1/4 hr)
31.
Read a college-oriented newspaper (FSView, etc.)
32.
Read a hometown newspaper (Tallahassee Democrat, Miami Herald, etc.)
33.
Read a national newspaper (USA Today, Wall Street Week, etc.)
34
ead a news magazine (Time, Newsweek, etc.)
One would click on V31 and then click on the arrow (>) pushbutton. The variable name would
appear in the Input variable --> Output variable box. Next, one would click on V32 and then the
arrow pushbutton. This would be repeated for V33 and V34.
Next, one-by-one, each variable in the Input variable --> Output variable box would be
highlighted, named and the Change pushbutton would be clicked.
After all four variables are named, one would click on the Old and New Values pushbutton and
then assign recoded values. When the RECODE procedure is completed, four new variables
would appear in the Data Editor (to the far right of previously existing variables/columns), each
recoded into categorical variables.

Opening RECODE Dialog Box for RECODE INTO SAME VARIABLES


1.

From the menus, click on TRANSFORM RECODE RECODE INTO SAME VARIABLES

2.

From the variable list click on the variable (or variables) you wish to Recode. Then, click on the
arrow (>) pushbutton. The variable name(s) will appear in the Numeric Variables: box. The "If..."
and the "Old and New Values" pushbuttons will then be highlighted. You will notice that, unlike
Recode into Different Variables, there is no renaming of the variable required.

3.

Click on OLD AND NEW VALUES. This will open the RECODE INTO SAME VARIABLES: OLD
AND NEW VALUES Dialog Box.
The procedure for recoding is identical to Recode into Different Variables. However, once you
click on OK, you replace the original values with the new values. If you then save the data file,
you have lost the original values for the variable. It is recommended that you avoid using
RECODE INTO SAME VARIABLES.

Selecting Subsets of Cases and IF CASES


The RECODE can be performed on a selected subset of cases by clicking on the IF... pushbutton in the
RECODE INTO SAME VARIABLES Dialog Box (or DIFFERENT VARIABLES). This opens the RECODE
INTO SAME VARIABLES: IF CASES dialog box (or DIFFERENT VARIABLES). This dialog box looks and
operates like the COMPUTE VARIABLES: IF CASES Dialog Box (see previous chapter on "IF CASES"
Chapter 16).
Categorize Variables
There is an alternative to Recode for creating groupings or categories for a continuous variable (creation
of "ntiles"). Categorize Variables creates a new variable and assigns a numeric value to each case. For
example, if you wish to categorize a continuous variable such as salary into quartiles, the procedure
assigns each case a value of 1, 2, 3 or 4 (for #4 or highest quartile, etc.) for the new variable it creates.
Click on TRANSFORM CATEGORIZE VARIABLES.
Select the variable you wish to collapse into categories. In the "Employee Data" file supplied by SPSS,
select the "Salary" variable.
Next, select the number of categories ("Number of categories"). Click on "OK". A new variable, "nsalary"
is created with values 1 through 4. The first case in the file has a salary of $57,000 and a value of "4" for
"nsalary".

Exercise 6
A.
1.

Open the file STUD94.SAV.

2.

For V6 to V17 RECODE (into different variables -- you might call them V6a, V7a, etc.).) values for
NO to zero -- that is, RECODE 2 to zero (0). Because you are creating new variables, you
must maintain the value of 1 (for YES) by RECODING 1 TO 1.

3.

Compute a new variable called TECH which is the sum of respondents scores on V6 to v17.

4.

Do a frequency analysis of TECH.

B.
1.

Open the SPSS supplied data file "Cars".

2.

Use the Categorize Variables option and recategorize the variable "weight" into three groups.

3.

Do a frequency analysis of the newly-created variable.

Paste the frequency tables from Parts A. and B. into Word. E-mail the file to your instructor as an
attachment. Be sure "Exercise 6" appears in the subject line of the email.

You might also like