In SPSS, how do I merge two files?

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 (e.g., 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.
  SORT CASE BY v1.
  SAVE OUTFILE = merge1.sav.

  GET FILE = merge2.sav.
  SORT CASE BY v1.
  SAVE OUTFILE = merge2.sav.

  MATCH FILES 
  /FILE=merge1.sav
  /FILE=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 Research Analytics. Research Analytics is located on the IU Bloomington campus at Woodburn Hall 200; staff are available for consultation Monday-Friday 9am-noon and by appointment.

Note:
For details about availability of UITS services during Thanksgiving break, see UITS Thanksgiving break support hours.

This is document aeqf in the Knowledge Base.
Last modified on 2015-06-19 00:00:00.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.