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.
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.
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.
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!