Simple Numeric Index (VARSTOCASES command)
A simple numeric index numbers the rows sequentially within a new group.
- The basic specification is /
INDEX=ivar
, where ivar is a name for the new index variable. - The new index variable starts with 1 and increments
each time a
FROM
variable is encountered in a row in the original file. After the lastFROM
variable is encountered, the index restarts at 1. - Gaps in the index sequence can occur if null data are dropped.
Example
VARSTOCASES
/MAKE newvar FROM var1 TO var4
/INDEX=ivar.
caseid ivar newvar
001 1 .00
001 2 .05
001 3 5.00
001 4 3.00
002 1 7.00
002 2 1.00
002 3 5.00
002 4 4.00
003 1 6.00
003 2 3.00
003 3 6.00
003 4 2.00