BY Subcommand (ADD FILES command)

BY specifies one or more key variables that determine the order of cases in the resulting file. When BY is specified, cases from the input files are interleaved according to their values for the key variables.

  • BY must follow the FILE subcommands and any associated RENAME and IN subcommands.
  • The key variables specified on BY must be present and have the same names in all input files.
  • Key variables can be string or numeric.
  • All input files must be sorted in ascending order of the key variables. If necessary, use SORT CASES before ADD FILES.
  • Cases in the resulting file are ordered by the values of the key variables. All cases from the first file with the first value for the key variable are first, followed by all cases from the second file with the same value, followed by all cases from the third file with the same value, and so forth. These cases are followed by all cases from the first file with the next value for the key variable, and so on.
  • Cases with system-missing values are first in the resulting file. User-missing values are interleaved with other values.