In SPSS, why were the results of my merge with MATCH FILES scrambled?
If the results of your merge using the MATCH FILES
command in SPSS are scrambled, follow the example below to fix your
data. If you wish to use SPSS graphical interface to fix the problem,
see SPSS graphical interface below.
The MATCH FILES command in SPSS merges two datasets to
add or update variables. Without a /BY or
/TABLE subcommand, the command sometimes produces odd
results by simply putting two data sets together. The problem becomes
worse when the index variable is not a unique identification variable.
Consider the following datasets and the MATCH FILES command:
Since ID, the index variable, has duplicate cases, SPSS gets
confused and gives you the warning message, "Warning # 5132 Duplicate key
in a file...", producing the following result. Notice that when SPSS found
a duplicate index, it automatically set the variable from DATA2
as missing and then went on to the next unique case.
To avoid this, use the /TABLE subcommand to tell SPSS that one
file will be used as a lookup table for the other dataset. SPSS will then
look through the file you defined with the /TABLE subcommand
and use it to match data to each field duplicated in the other file,
for example:
The command with /TABLE will produce the following dataset:
SPSS graphical interface
To merge data using SPSS graphical interface:
- Open the data file
Data1.sav.
- From the
Datamenu, selectMerge Filesand thenAdd Variables....
- Select the file to merge (e.g.,
Data2.sav), and then clickContinue.
- In the
Add variablesdialog box, selectMatch cases on key variables in sorted filesand checkNon-active dataset is keyed table. Under "Key Variables:", selectID. ClickOK.This will produce the same results as the example using the
MATCH FILEScommand above. It is important to sort both the data files by key variable(s) before you merge them.
For more about statistical and mathematical software, email the UITS Stat/Math Center, visit the center's web page, or phone 812-855-4724 (IUB) or 317-278-4740 (IUPUI). The center is located in Bloomington at 410 N. Park Avenue, and is open for consultation by appointment Monday-Friday 9am-5pm.
Last modified on May 11, 2011.







