Merging Files Using SPSS

This Tech Tip was provided by Fnu Mihir, Director of Institutional Research, Norwalk Community College.

Oftentimes, we merge data to add variables from different sources, such as tables or files, into one table or file. Using SPSS to merge files (i.e., to add variables) is very useful. However, the key to merging two data files in SPSS lies in how the variables were defined and the duplication of the variables. Before merging two files to add variables to a dataset in SPSS, confirm the following.

  1. The primary or key variable (the common variable in datasets -- i.e., a student identifier or course number) must be unique. If you have duplicates in the dataset, be sure to aggregate the file such that one row represents one identifier. If you still have duplicates, SPSS will not perform the merge.

  2. Make sure the primary variable is defined (variable name, type, and length) the same in both files. For example, if Student_ID is numeric with width set to 9 and decimals to 0, make sure the second file has the same variable name (Student_ID) and variable type.

  3. Make sure the primary variable is sorted (Data -> Sort Cases) either in ascending or descending order. Remember to sort the same way in both files.

Save both files. To merge files, click Data -> Merge Files -> Add Variables.

Happy merging in SPSS!


To add a comment, Sign In
Total Comments: 1
Mike posted on 5/26/2012 3:18 PM
In addition to the steps described here, I will usually use SPSS's "in" subcommand to create indicator variables or flags which are 1 if a case has successfully been matched, and 0 if not. After the match files command, I immediately do a crosstab of the two indicator variables to see the number of successful matches and the number of "orphans".