SPSS Tutorials

BASICS REGRESSION T-TEST ANOVA CORRELATION

SPSS Transformation Commands

Summary

SPSS transformation commands (or simply “transformations”) can be loosely defined as commands that are not immediately carried out when you run them. Instead, they are kept in mind by SPSS and executed only when necessary. The table below gives an overview of SPSS' main tranformation commands.

Main SPSS Tranformation Commands

Command NameGoalTypical usage
COMPUTECreate variableVery frequently
RECODECreate variableVery frequently
IFCreate variableVery frequently
COUNTCreate variableSometimes
SELECT IFDelete casesVery frequently
SAMPLEDelete casesVery rarely
DO IFControl other transformationsSometimes
DO REPEATControl other transformationsFrequently
LOOPControl other transformationsSometimes
TEMPORARYControl other transformationsFrequently
LEAVEControl other transformationsVery rarely
ADD FILESMerge dataSometimes
MATCH FILESMerge dataSometimes
UPDATEMerge dataVery rarely
DATA LISTDefine new dataRarely
INPUT PROGRAMDefine new dataVery rarely
WRITECreate data fileVery rarely
XSAVECreate data fileVery rarely

SPSS Tranformations Pending

For a better understanding of what SPSS transformations are, let's run one. For example, let's open age_income.sav and COMPUTE yearly incomes as income * 12. We'll do so by running the syntax below. compute yearly_income = income * 12. Immediately after doing so, the resulting variable seems to hold only system missing values in data view. This result is shown in the screenshot below.

SPSS Transformations Pending

Note the message “Transformations pending” in the status bar. SPSS knows you ran one or more tranformations and it's keeping these in mind until it actually needs to execute them.

SPSS Procedures

Now let's run some basic DESCRIPTIVES over our new variable by running descriptives yearly_income. Unsurprisingly, we now see in the Output Viewer window that 30 respondents have an average yearly_income of € 30013,-. Perhaps more surprisingly, the values for yearly_income have now appeared in data view and “Transformations pending” has disappeared.

SPSS Transformations Executed

Clearly, running DESCRIPTIVES has caused the execution of our pending tranformation. Commands that execute pending transformations are collectively known as procedures in SPSS. Keep in mind here that in SPSS, “procedure” has a different meaning than in normal language. A special case is EXECUTE which does nothing except executing pending transformations.

Why doesn't SPSS simply execute transformations as soon as they are run? Well, the basic answer is that doing so makes SPSS slower, especially for data that contain a vast number of cases. This also implies that using EXECUTE when it's not necessary renders your syntax slower, although on modern computers the difference may be noticeable only on huge datasets.

SPSS Transformations - Why Bother?

Why should you care whether a command is a transformation, procedure or other SPSS command? Well, the basic reason is that some important SPSS commands can only be combined with tranformations, not procedures.
For instance, if you try to place DESCRIPTIVES in a LOOP, you'll merely trigger an error.

SPSS Transformations Executed

The reason is that DESCRIPTIVES is a procedure and you can only use tranformations in a LOOP. Understanding the difference between tranformations, procedures and other SPSS commands circumvents such errors and the confusion they cause among SPSS users.Looping over procedures is possible too but not with the LOOP or DO REPEAT commands. Instead, Python is the way to go here, an example of which shown in Regression over Many Dependent Variables.
A list of commands that can't be combined with procedures is presented in the overview we saw earlier. They have been labelled “Control other transformations”.TEMPORARY is not restricted to transformations but details on this are beyond the scope of this tutorial.

SPSS Transformation Test

Ok, so commands such as DO IF and DO REPEAT combine only with transformations. But how can you know whether a given command is a transformation or not? Well, for one thing, the CSR indicates for each command whether it's a transformation, procedure or other command. For example, the text below indicates a transformation.

SPSS Transformations in CSR

Since many SPSS users find the CSR “unreadable”, an alternative option is simply trying: run a single command an see whether or not it triggers the “Transformations pending” notification.
Sure, such trial and error will cost some effort initially. However, practice really does make perfect; in the end, figuring out how things work will save you much more time than it will cost you.

Previous tutorial: Target Population

Next tutorial: Change Your Working Directory

Let me know what you think!

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