SPSS Analysis Tips: The Temporary Command

Survey Tips
August 11, 2010

Working as a research supplier can be challenging, especially when the client is a large company with many decision makers. Most of my clients are senior-level business managers that have a preferred way to view data (Mean, Top-2 box, Top-box, Bottom-3 box, etc.)

In fact, it is rare that I don’t have to create the same exact report displaying the data in the previous mentioned ways. Thankfully by using SPSS syntax, and some planning, this can be painless.

The Temporary command allows you to temporarily transform the data without making permanent changes. The transformation works for the very first procedure, then it reverts back to the original values.

Here is the data file created from this questionnaire within Alchemer 3.0. (I took advantage of the new “Generate Test Data” feature in 3.0).

If you simply run Descriptive statistics on the data file you will get the average for each variable. Here is the syntax for obtaining the means sorted lowest to highest:


You should see a table similar to the following table (Mine will look slightly different as I have scripts that automatically run and tweak my output)

Now what if your client wanted the top-3 box instead of mean? TEMP to the rescue! Simply Add two lines in front of the Descriptives command as I have below:

RECODE hot to elephant (1 thru 4=0) (5 thru 7=1).
DESCRIPTIVES hot to elephant /STATS=MEAN /SORT (a).

Make sure that, when you run the code, you run all three lines. If you only run the 2nd and 3rd line the transformation will not be temporary and you’ll end up transforming your data. (This is probably okay as you haven’t saved it, however, you’ll have to reload the data file if you wish to have the original values)

If your client were to want the top two box, simply change the recode line to the following:

RECODE hot to elephant (1 thru 5=0) (6 thru 7=1).

Other Uses Of Temporary

Does Temporary have other uses? Why, yes it does. Let’s say that for a particular graph you wanted to tweak the variable labels. Below is an example using Temp with variable labels and recoding to show top box.

RECODE hot to elephant (1 thru 6=0) (7=1).
VAR LABEL elephant “No idea elephant…”.

Another common way I use the Temp command is when I wish to suppress a small sized group when reviewing the ANOVA test via the Means command. The following syntax runs the Means command with that ANOVA test to see if there is a statistical difference on the elephant statement by gender.


As you’ll see there were 13 respondents that did not know their Gender. (Perhaps the crying game fan club?) Anyway, the ANOVA test (not shown here) comes up with a Significance value of .001 (meaning 1 time in 1,000 this difference would have been found simply due to chance) Looking a little closer at the scores, the average of the “Don’t know” group is very low. What would happen if we were to exclude them out from the test?

A quick way to do this is to temporarily define them as missing. The following code does this as well as runs the means test.


Notice that now when only comparing between Men and Women, the significance level is .115 (We probably would not state there is a difference between them)

Using With Select If Statements

On my larger studies, I frequently have to run the report for various business departments, Regions, Countries, etc. On shorter reports, combining the TEMP command with SELECT IF is very helpful. For instance, if we wanted to show the top-2 box scores for Males, we would use the following:

SELECT IF gender=1.

On longer reports, where I’m creating an entire sub-report on a given country, region, etc., I typically use the SELECT IF statement without the TEMP command. This allows me to filter the data once and run the entire report. I just make certain not to save the data after I’ve filtered it.

Those were some quick tips on using the TEMP command within SPSS so you can analyze your survey data even further.

  • Get Your Free Demo Today
    Get Demo
  • See How Easy Alchemer Is to Use
    See Help Docs
  • Start making smarter decisions

    Start a free trial