Concatenate files in SPSS

In SPSS, use the ADD FILES command to concatenate or append two or more data files. The files must be SPSS system files. To concatenate them simply, list the files to be merged using the /FILE subcommand. The concatenation follows the order of the files specified.

This first example adds three files called PART1.sav, PART2.sav, and PART3.sav in the c:\spssdata directory:

  ADD FILES
    /FILE="C:\spssdata\PART1.sav"
    /FILE="C:\spssdata\PART2.sav"
    /FILE="C:\spssdata\PART3.sav".
  EXECUTE.

You can also index the files on a specific variable (such as case ID) if you wish; this is called interleaving files. The files are organized on the variable ID, so that the final saved data set is indexed according to this shared variable. Notice that the order of the files read into SPSS is reversed, but the final product is the same due to the /BY subcommand.

  ADD FILES
    /FILE="C:\spssdata\PART3.sav"
    /FILE="C:\spssdata\PART2.sav"
    /FILE="C:\spssdata\PART1.sav"
    /BY=ID.
  EXECUTE.

If you have questions about using statistical and mathematical software at Indiana University, contact the UITS Research Applications and Deep Learning team.

This is document aeqq in the Knowledge Base.
Last modified on 2019-02-07 13:26:39.

Contact us

For help or to comment, email the UITS Support Center.