SPSS tutorials website header logo SPSS TUTORIALS BASICS ANOVA REGRESSION FACTOR CORRELATION

SPSS – Recode with Value Labels Tool

This tutorial presents a simple tool for recoding values along with their value labels into different values.

Example Data

We'll use recode-with-value-labels.sav -partly shown below- for all examples.

SPSS Recode With Value Labels Variable View

These data contain several common problems:

Some variables must be reverse coded because they measure the opposite of the other variables within some scale.
Some ordinal variables are coded as string variables.

The tool presented in this tutorial is the fastest option to fix these and several other common issues.

Prerequisites & Installation

Our recoding tool requires SPSS version 24+ with the SPSS Python 3 essentials properly installed -usually the case with recent SPSS versions.

Next, download our tool from SPSS_TUTORIALS_RECODE_WITH_VALUE_LABELS.spe. You can install it by dragging & dropping it into a data editor window. Alternatively, navigate to Extensions SPSS Menu Arrow Install local extension bundle as shown below.

SPSS Extensions Install Local Extension Bundle

In the dialog that opens, navigate to the downloaded .spe file and select it. SPSS now throws a message that “The extension was successfully installed under Transform - SPSS tutorials - Recode with Value Labels”. You'll now find our tool under Transform SPSS Menu Arrow SPSS tutorials - Recode with Value Labels as shown below.

SPSS Recode With Value Labels Tool Menu

Checking Results & Creating New Variables

If you use our tool, you may want to verify that all result are correct. A basic way to do so is to compare some frequency distributions before and after recoding your variables. These will be identical (except for their order) if you show only value labels in your output.

Our tool modifies existing variables instead of creating new ones. If that's not to your liking, combine it with our SPSS Clone Variables Tool (shown below).

SPSS Clone Variables Dialog 1

A very solid strategy is now to

Ok, so let's now see how our recoding tool solves some common data problems.

Example I - Reverse Code Variables

Conf01 to Conf06 are intended to measure self confidence. However, Conf04 and Conf06 indicate a lack of self confidence and correlate negatively with the other confidence items.

This issue is solved by reverse coding these items. After installing our tool, let's first navigate to Transform SPSS Menu Arrow SPSS tutorials - Recode with Value Labels Next, we'll fill out the dialogs as shown below.

SPSS Recode With Value Labels Example 1

Excluding the user missing value of 8 (No answer) leaves this value and its value label unaltered.

Completing these steps results in the syntax below. Let's run it.

*REVERSE CODE CONF04 AND CONF06.

SPSS TUTORIALS RECODE_WITH_VALUE_LABELS VARIABLES=Conf04 Conf06 OLDVALUES=1 2 3 4 5 6 7 NEWVALUES=7
    6 5 4 3 2 1
/OPTIONS LABELSUFFIX=" (R)" ACTION=RUN.

Result

SPSS Recode With Value Labels Result 1

Note that (R) is appended to the variable labels of our reverse coded variables;
The values and value labels have been reversed as well.

Our reverse coded items now correlate positively with all other confidence items as required for computing Cronbach’s alpha or a mean or sum score over this scale.

Example II - Correct Order after AUTORECODE

Another common issue are ordinal string variables in SPSS such as suc01 to suc06 which measure self-perceived successfulness. First off, let's convert them to labeled numeric variables by navigating to Transform SPSS Menu Arrow Automatic Recode Next, we'll create an AUTORECODE command for a single variable as shown below.

SPSS Automatic Recode Example

We can now easily add the remaining 5 variables to the resulting SPSS syntax as shown below. Let's run it.

*CONVERT STRING VARIABLES INTO NUMERIC ONES.

AUTORECODE VARIABLES=suc01 to suc06 /* ADD ALL OLD VARIABLES HERE */
/INTO nsuc01 to nsuc06 /* ADD ALL NEW VARIABLES HERE */
/GROUP
/PRINT.

This syntax converts our string variables into numeric ones but the order of the answer categories is not as desired. For correcting this, we first copy-paste our new, numeric values into Notepad++ or Excel. This makes it easy to move them into the desired order as shown below.

SPSS Recode With Value Labels Desired Order

Doing so makes clear that we need to

The figure below shows how to do so with our recoding tool.

SPSS Recode With Value Labels Example 2

This results in the syntax below, which sets the correct order for our autorecoded numeric variables.

*FIX CATEGORY ORDER AFTER AUTORECODE.

SPSS TUTORIALS RECODE_WITH_VALUE_LABELS VARIABLES=nsuc01 nsuc02 nsuc03 nsuc04 nsuc05 nsuc06
    OLDVALUES=9 3 7 4 6 2 8 5 1 NEWVALUES=1 2 3 4 5 6 7 8 9
/OPTIONS ACTION=RUN.

Example III - Convert 1-2 into 0-1 Coding

In SPSS, we preferably use a 0-1 coding for dichotomous variables. Some reasons are that

The syntax below is easily created with our recoding tool and converts the 1-2 coding for all dichotomous variables in our data file into a 0-1 coding.

*CHANGE 1-2 CODING TO 0-1 CODING FOR SEVERAL VARIABLES.

SPSS TUTORIALS RECODE_WITH_VALUE_LABELS VARIABLES=somed01 somed02 somed03 somed04 somed05 somed06
    somed07 OLDVALUES=2 NEWVALUES=0
/OPTIONS ACTION=RUN.

Example IV - Correct Coding Errors with Native Syntax

If we take a close look at our final variable, sat01, we see that it is coded 21 through 27. Depending on how we analyze it, we may want to convert it into a standard 7-point Likert scale. The screenshot below shows how it's done.

SPSS Recode With Value Labels Example 3

Note that we select “Create syntax and print it” for creating native syntax.

Result

As shown below, selecting the print option results in native SPSS syntax in your output window.

SPSS Recoding Tool Native Syntax

The syntax we thus copy-pasted from our output window is:

*CORRECT CODING WITH NATIVE SYNTAX.

RECODE sat01 (21.0 = 1.0)(22.0 = 2.0)(23.0 = 3.0)(24.0 = 4.0)(25.0 = 5.0)(26.0 = 6.0)(27.0 = 7.0).
EXECUTE.
VALUE LABELS
/sat01 1.0 'Strongly disagree' 2.0 'Disagree' 3.0 'Slightly disagree' 4.0 'Neutral' 5.0 'Slightly agree' 6.0 'Agree' 7.0 'Strongly agree'.

Note that it consists of 3 very basic commands:

So why should you consider using the print option? Well, the default syntax created by our tool only runs on SPSS installations with the tool installed. So if a client or colleague needs to replicate your work, using native syntax ensures that everything will run
on any SPSS installation.

Right, so that should do. I hope you'll find my tool helpful -I've been using it on tons of project myself. If you've any questions or remarks, just throw me a comment below, ok?

Thanks for reading!

Tell us what you think!

*Required field. Your comment will show up after approval from a moderator.

THIS TUTORIAL HAS 21 COMMENTS: