Merge two files in SPSS

The most common form of merging is what SPSS calls a parallel "matched merge", where two files are sequentially organized and combined to create one large file. To complete this process, each file must contain the same shared unique identification variable; this is used to sort on and then to merge on. This variable is the key by which the final merged file will be organized, and serves as an index of the process (for example, record number or ID number).

To implement the merge:

  1. Use the SORT CASE command to sort each file you wish to merge on the index variable.
  2. After sorting, use the SAVE OUTPUT command to save each file to a systems file.
  3. Use the MATCH FILES command to merge the files and create a single, final version of the file.

The following example of this process merges two files, merge1.sav and merge2.sav, with the shared index variable v1, into a final file, sort.sav:

  GET FILE = merge1.sav.
  SAVE OUTFILE = merge1.sav.

  GET FILE = merge2.sav.
  SAVE OUTFILE = merge2.sav.

  /BY v1.

  SAVE OUTFILE = sort.sav.

For other types of file merging or more information, see the SPSS Command Syntax Reference (PDF).

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 aeqf in the Knowledge Base.
Last modified on 2019-01-31 15:30:43.