Research Design and Statistical Consulting
George M. Diekhoff, Ph.D.

An SPSS Syntax Trap

Every so often changes are made in SPSS syntax that can catch one by surprise. For instance, a few versions back, one could write a couple simple lines of syntax to specify that analyses beyond that point would run on only a select group of cases.
For instance, if you wanted to run an analysis on only cases whose age was less than 30, you could type these two lines in a syntax file and run them:
SELECT IF (AGE LT 30).
EXECUTE.
Those two lines of syntax would simply tag unselected cases (i.e., cases who were 30 and older) and not include them in the analysis, but the cases still remained in the data file.
At some point in the fairly recent past, however, the rules changed! Running those same two lines now doesn’t just exclude the cases from the analysis, but DELETES THEM FROM THE DATA FILE!!
The syntax required to select a subset of cases for analysis, but still leave the other cases in the data file, is a lot more complex. For the example above, where you wanted to select cases for subsequent analysis who were less than 30 years old:
USE ALL.
COMPUTE filter_$=(AGE LT 30).
VARIABLE LABELS filter_$ ‘AGE LT 30 (FILTER)’.
VALUE LABELS filter_$ 0 ‘Not Selected’ 1 ‘Selected’.
FORMATS filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.
Yikes! I recommend that you use the menu system to generate the necessary syntax and then paste it into your syntax file in the appropriate location:
Data > Select Cases > Check “If condition is satisfied” > Click the “If…” button > type in “age lt 30” (without the quotes) > Click the “Continue” button > Click the “OK” button.

s