EXECUTE runs pending transformations.
However, many SPSS users don't have a clue what that means. More importantly, when should you (not) run EXECUTE? And when do you really *need* it?

Let's dive in. We'll use adratings.sav throughout, part of which is shown below.

## SPSS “Transformations Pending”

As you probably figured out, our data hold 18 respondents who rated 3 different advertisements. Now let's say we need to compute a corrected version of ad1 which we'll name cad1 by adding 10 points to each score.

The easy way is a simple COMPUTE command like
compute cad1 = ad1 + 10.
If you run just this syntax, your data view will look like below.

So what's “transformations pending” in the status bar? And where's my corrected scores? I told SPSS to compute them and it hasn't done so! [email protected]#$%g SPSS!

However, just running
execute.
successfully completes our transformation.

## So Why Did we Need EXECUTE?

Basically everything we do in SPSS is done by **commands**. You may not see those if you work directly from the menu -a recipe for disaster as explained in SPSS Syntax - Six Reasons you Should Use it.

But anyway, SPSS commands come in 3 basic types:

**procedures**are commands that must inspect all cases. Some examples are FREQUENCIES, DESCRIPTIVES and SORT CASES plus all charts and statistical tests. These commands require SPSS to “go through” all cases straight away.**transformations**are commands that will inspect all cases but this only happens when really needed. Well known transformations are COMPUTE, RECODE, IF and SELECT IF.**other commands**that don't inspect any cases. Examples are FILTER, VARIABLE LABELS and ADD VALUE LABELS.

If you want to know if a command is a procedure, transformation or other, consult Overview All SPSS Commands.Yes, I know. I need to update it. Any volunteer for that?

Now imagine that you're SPSS -it isn't hard to do. You have data with 100,000 cases open. If somebody asks you to COMPUTE something, you must go through all 100,000 cases. Quite a job!

Then, if the user asks for FREQUENCIES, you must go through all 100,000 cases *again*. So in order to save computing time (and electricity)
SPSS prefers to go through all cases just once
and do the COMPUTE and FREQUENCIES in one go. So that's why it won't immediately execute some commands -which are known as transformation commands.

## SPSS Transformation Commands

Now if we consult the command syntax reference on COMPUTE, we see the following:

COMPUTE is a TransformationThe phrase “it is stored, pending” indicates that COMPUTE is a **transformation**. This means that we need to EXECUTE it if we want to inspect the result in the data editor before proceeding.

## SPSS Procedures

If we look up FREQUENCIES, the fine manual tells us that

FREQUENCIES is a Procedureand a command that “reads the active dataset” is a **procedure**.

This means that
running EXECUTE right before FREQUENCIES is pointless
and merely slows down SPSS.

The same goes for EXECUTE right after VARIABLE LABELS or RENAME VARIABLES: these are not transformations but take place immediately so there aren't any pending transformations to execute.

Importantly, some commands that transform your data are technically procedures, not transformations. Examples are ALTER TYPE, AGGREGATE and RANK.

## So When To Use EXECUTE?

- Use EXECUTE if you have transformations pending and you want to
**visually inspect results**before doing anything else. - In rare cases, you
**need EXECUTE**in order for your syntax to run correctly.

So when do you *really need* EXECUTE? I'm familiar with 3 scenarios so I'll present them below. Again, all examples use adratings.sav.

## 1. EXECUTE Before DELETE VARIABLES

***Wrong way to compute total and delete input variables.**

compute total = sum(ad1 to ad3).

delete variables ad1 to ad3.

***Right way to compute total and delete input variables.**

compute total = sum(ad1 to ad3).

**execute.**

delete variables ad1 to ad3.

## 2. EXECUTE Before LAG Function

***Wrong way to compute ad1 for previous case, then add 10 to original ad1.**

compute prev_ad1 = lag(ad1).

compute ad1 = ad1 + 10.

execute.

***Right way to compute ad1 for previous case, then add 10 to original ad1.**

compute prev_ad1 = lag(ad1).

**execute.**

compute ad1 = ad1 + 10.

execute.

## 3. EXECUTE After Using $Casenum

***Wrong way to delete first 10 cases.**

compute casenum = $casenum.

select if casenum > 10.

execute.

***Right way to delete first 10 cases.**

compute casenum = $casenum.

**execute.**

select if casenum > 10.

execute.

I guess that's about it. Hope you liked it. Do you have any other examples in which you really need EXECUTE? Please drop me a comment below and let me know.

Thanks for reading!