Recoding Variables in SPSS Menus and Syntax

by Karen Grace-Martin

SPSS offers two choices under the recode command: Into Same Variable and Into Different Variables.

The command Into Same Variable replaces existing data with new values, but the command Into Different Variables adds a new variable to the data set.

In almost every situation, you want to use Into Different Variables. Recoding Into Same Variables replaces the values in the existing variable.

So if you notice a mistake after you’ve recoded, you can’t fix it.

But you may not even notice the mistake, because you can’t even test it.

And that’s just dangerous.

So do not recode over an existing variable unless you are absolutely certain that the lost information will never be needed.

Here is an example of how to do it in the menus.  This is from the General Social Survey data set that comes along with SPSS.  In it, I am recoding Educ, Years of Education, into 5 categories: Less than High School, High School Grad, Some College, Bachelor’s degree, More than college.


Recode  Into Different Variables

This dialog window will come up:

I filled in the following:

Numeric variable: Educ

Output variable Name: Educ_Cat

Output variable Label: Education in Categories

Click Change

Click Old and New Values

This Dialogue Window will pop up:

Fill in the following:

Old Value: Range: Lowest Through: 11

New Value: Value: 1

Click Add

Old Value: Value 12

New Value: Value: 2

Click Add

Old Value: Range: 13 Through: 15

New Value: Value: 3

Click Add

Old Value: Value: 16

New Value: Value: 4

Click Add

Old Value: Range: 17 Through Highest

New Value: Value: 5

Click Add

Old Value: System- or User-Missing

New Value: System Missing

Click Continue

Click OK
Or, you could do all of that in just a few lines of very logical syntax code:

RECODE educ (12=2) (16=4) (MISSING=SYSMIS) (Lowest thru 11=1) (13 thru 15=3) (17 thru Highest=5) INTO Educ_cat.
VARIABLE LABELS  Educ_cat ‘Education in Categories’.

If you don’t have many variables to recode, say one or two, it’s not a big deal to use the menus (but at least paste the code, so you have a record of what you did later!).

But if you have more than just one or two, all those mouse-clicks get old, fast.

And if you need to go back and change your coding scheme, say to combine two small categories, it’s a quick matter to update the code.  In the menus you have to start over.

(And of course, once you recode, you should immediately enter value labels and test your syntax to make sure it worked.  Both are easy to do with syntax).

Want to learn more? If you’re just getting started with data analysis in SPSS, or would like a thorough refresher, please join us in our online workshop Introduction to Data Analysis in SPSS.

Bookmark and Share

Getting Started with SPSS Syntax
Do you want to know how to use SPSS syntax for data manipulation and analyses? You will witness all the advantages that come with using syntax, especially one that is already built-in.

{ 2 comments… read them below or add one }


1. Imported Data
2. Recoded variables into new variables
How do I add more data into the sheet?
If I do a simple copy paste value is not being generated for the recoded variables. Help !!



i have spss sheet.and i make variable from different items now i have loss output file and dont know about the items of the variable. how i know about the items. variable are developed already…


Leave a Comment

Please note that, due to the large number of comments submitted, any comments on problems related to a personal study/project will not be answered. We suggest joining Statistically Speaking, where you have access to a private forum and more resources 24/7.

Previous post:

Next post: