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.

Check out our Free Webinar Recordings, including topics like: Missing Data, Mixed Models, Structural Equation Modeling, Data Mining, Effect Size Statistics, and much more...

Bookmark and Share

{ 1 comment… read it below or add one }

Nummy October 26, 2016 at 2:27 am

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 Karen receives hundreds of comments at The Analysis Factor website each week. Since Karen is also busy teaching workshops, consulting with clients, and running a membership program, she seldom has time to respond to these comments anymore. If you have a question to which you need a timely response, please check out our low-cost monthly membership program, or sign-up for a quick question consultation.

Previous post:

Next post: