This tutorial presents a simple tool for recoding values along with their value labels into different values.
- Prerequisites & Download
- Checking Results & Creating New Variables
- Example I - Reverse Code Variables
- Example II - Correct Order after AUTORECODE
- Example III - Convert 1-2 into 0-1 Coding
- Example IV - Correct Coding Errors with Native Syntax
Example Data
We'll use recode-with-value-labels.sav -partly shown below- for all examples.

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
as shown below.

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
as shown below.
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).

A very solid strategy is now to
- clone all variables you'd like to recode;
- recode the original (rather than the cloned) variables with our recoding tool;
- compare the recoded variables with their cloned counterparts with CROSSTABS;
- optionally: remove the cloned variables from your data when you're done.
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
Next, we'll fill out the dialogs as shown below.
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.
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

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 AUTORECODE command for a single variable as shown below.
Next, we'll create an
We can now easily add the remaining 5 variables to the resulting SPSS syntax as shown below. Let's run it.
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.

Doing so makes clear that we need to
- convert 9 into 1,
- convert 3 into 2,
- convert 7 into 3,
- and so on...
The figure below shows how to do so with our recoding tool.

This results in the syntax below, which sets the correct order for our autorecoded numeric variables.
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
- this facilitates interpreting b-coefficients for dummy variables in multiple regression;
- means for 0-1 coded variables correspond to proportions of “yes” answers which are easily interpretable.
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.
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.

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.

The syntax we thus copy-pasted from our output window is:
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:
- RECODE adjusts the values themselves;
- EXECUTE can usually be removed from the syntax but it ensures that our RECODE is executed immediately;
- VALUE LABELS adjusts our value labels after our RECODE.
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!
THIS TUTORIAL HAS 21 COMMENTS:
By José-Luis Martínez-Cantos on September 2nd, 2020
Hello:
Thank you so much for this useful tool! Great job.
I have to say that it has a little problem. If you re-code/re-label a variable with, e.g., values 1 and 2 to values 0 and 1, the label for value 2 will still remain and appear in custom tables as a (blank) category.
It would be fantastic if you could you fix that, so the labels for "discarded" values (2 in the example) are automatically deleted.
Best,
By Ruben Geert van den Berg on September 3rd, 2020
I totally see your point and I'll think it over.
However, "empty" value labels don't usually present that much of a problem because they usually don't appear in output charts and tables. The main exceptions are
-custom tables and
-the chart builder (usually a poor choice for creating charts anyway)
Both dialogs/syntaxes allow you to not include "empty categories". So I don't see any urgent reason to remove empty value labels and doing so is rather cumbersome anyway.
But OK, if we ever come up with a new version of the tool we'll look into it.
Keep up the great work!
SPSS tutorials
By beau on May 5th, 2021
Hi,
I'm having trouble installing the fixed version (the change category order one). I'm getting this error:
"Error saving dialog specification. You must have write permission to the deployment directory.
1. Cannot write to file: /private/var/folders/1q/wt9q5wxn6rb1c170fn4s9lmc0000gn/T/spss88879/_uibuilder3924654562810417132.tmp/C:\Users\Ruben\Desktop\RIMG\mini_logo2.png."
Do you happen to know how to get around this?
Beau
By Ruben Geert van den Berg on May 6th, 2021
Hi Beau!
I think you can fix this by running SPSS as an administrator. However, there's a much newer and better version of this tool at SPSS_TUTORIALS_RECODE_WITH_VALUE_LABELS.spe (requires SPSS 24+ with Python3).
I think the new version should install fine. If not, please let us know.
Kind regards,
SPSS tutorials
By Jon K Peck on March 27th, 2023
The SPSSINC RECODEEX extension command, available via Extensions > Extension Hub, provides the ability to generate value labels for the recoded variable from the value labels of the input. It can also copy variable labels.
From the syntax help...
VALUELABELS specifies whether value labels should be created for the output values. They will consist of the input values that are mapped to each output with two caveats: An ELSE specification does not contribute to the labels. If an input value is mapped to more than one output value, it will appear in each corresponding value label even though the RECODE command processes from left to right. If the generated label is too long, it is truncated and … is appended.
USEINPUTVALLABELS specifies whether the created value labels should contain the input values or their value labels. This keyword is ignored if VALUELABELS=NO. If the input value labels are used and a range specification appears, that specification is used as the value label.
If COPYVARIABLELABELS=YES, the variable label, if any, of each input variable will be copied to the output variable. PREFIX and SUFFIX can specify text to be prepended or appended to the label with a separating blank.