Both files need to have a common indexing key. This would be a unique identifier for each case in your data set. Both data files should provide different data for the same set of cases. The keys have to be sorted in accending order for SPSS to be able to merge the files, so make sure both files are sorted in ascending order before trying to merge.
Open the first file that you wish to merge. Next under the 'Merge Files' item in the 'Data' menu, select 'Add Variables...'
Select the file you wish to merge
If both keys have the same name one will show up in the 'Excluded Variables' list. This will be the variable we will match our cases on. If your key variables had different names you should rename one so they both have the same name. Select the key variable from the 'Excluded Variables' list. Check the 'Match cases on key variables in sorted files' checkbox. Select the 'Bothe files provide cases' radio button. Now press the right arrow button that is next to the 'Key Variables:' list box.
Pressing the left arrow button in the previous step should have pushed the key variable into the 'Key Variables': list box. You should also notice that your key varaible is no longer listed in the 'New working Data File:' list box. Items in the 'New Working Data File:' list box will have a (*) next to them if they were in your first data file and a (+) next to them if they are being added from your importing data file. If you wish not to add any variables to your new data set select them in the 'New Working Data File:' list box and press the right arrow button between the 'Excluded Variables' and 'New Working Data File' listbox. Once everything is in order press the OK button.
SPSS will give you a warning regarding sorted key variables. Make sure both files were sorted in ascending order before trying to do a file merge.
If all goes as planned all variables from both files will be merged in a new datafile. Cases are matched were matched by the key variable (case# in this example)
send questions, comments, and suggestions to firstname.lastname@example.org
back to SPSS Tutorials.