Troubleshooting
Problem
I was trying to select cases where $CASENUM was greater than 1. This should have selected all but the first case, but all the cases were deleted from the active file. This occurred when I selected Delete instead of Filtered. What is going on?
Resolving The Problem
The following syntax:
SELECT IF ($casenum > 1).
will never select a case. Why? Because $CASENUM is a "dynamic" variable in that it can change values. In this instance, we ask
Statistics to select cases with a $CASENUM value greater than 1. Statistics looks at the first case, sees a $CASENUM value of 1, and throws
it out of the analysis. At this point case 2, which had a $CASENUM value of 2, now has a value of 1. Statistics runs the SELECT IF command
against that case, and throws it out. Case 3, which originally had a $CASENUM value of 3, then had a value of 2 when case 1 was selected out,
now has a $CASENUM value of 1, and it gets selected out of the data set, and so on, and so on.
It is easy to get around this by creating a variable which is equal to the $CASENUM variable. This can be done with the COMPUTE
command. Then, you may select that cases based on the new variable.
The syntax for this command is simply
COMPUTE newvar=$casenum
Related Information
Historical Number
17545
Was this topic helpful?
Document Information
Modified date:
16 April 2020
UID
swg21476175