FIRST and LAST Subcommands (ADD FILES command)

FIRST and LAST create logical variables that flag the first or last case of a group of cases with the same value on the BY variables. FIRST and LAST must follow all FILE subcommands and their associated RENAME and IN subcommands.

  • FIRST and LAST have only one specification, the name of the flag variable.
  • FIRST creates a variable with the value 1 for the first case of each group and the value 0 for all other cases.
  • LAST creates a variable with the value 1 for the last case of each group and the value 0 for all other cases.
  • Variables created by FIRST and LAST are automatically attached to the end of the resulting file and cannot be dropped.

Example

ADD FILES  FILE="/data/school1.sav" /FILE="/data/school2.sav"
 /BY=GRADE /FIRST=HISCORE.
  • The variable HISCORE contains the value 1 for the first case in each grade in the resulting file and the value 0 for all other cases.