"$CASENUM EQ 1" may not mark the first data pass

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

"$CASENUM EQ 1" may not mark the first data pass

Richard Ristow
Many of us use "$CASENUM EQ 1" as a marker for the beginning of a transformation program - I've done it lots of times:

DO IF  $CASENUM EQ 1.
.  <commands to be executed only at the>  .
.  <start of the transformation program>  .
END IF.

Mostly that works, but it won't if you have a SELECT IF that drops cases at the beginning of the file. When you drop the first case in the file, the next case gets $CASENUM 1, and the 'one-time' code runs again for that case, ...

Below is an alternative. It relies on scratch variables being initialized to 0, and then keeping any value they have until they're explicitly re-assigned.

NUMERIC     #DoneInits (F2).
DO IF   NOT #DoneInits.
.  COMPUTE  #DoneInits = 1.
.  <commands to be executed only at the>  .
.  <start of the transformation program>  .
END IF.

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD