Add variables from one SPSS file to another SPSS file

I have two SPSS files, and both files have a common (key) variable "case number." One SPSS file has no duplicate case numbers, but the other one does have duplicate case numbers.

I need to add a few variables from the file that does not have duplicate case numbers to the file that has duplicate case numbers.

For example, if case number 123 is "male" in the data set with only one case number 123, I want to add variable "male" to all entries in the other data set that is associated with case number 123.

Is there any way to do this?

My understanding is that if I cannot use "match cases on key variables" and/or "Cases are sorted in order of key variables in both data sets" if there are duplicate key variables in one of the spss files. This is the error message SPSS gives me:

Error # 5131

Duplicate key on a TABLE file. Each case on a TABLE file in MATCH FILES must be uniquely identified by the BY variables.

Execution of this command stops.

However, I don't know any other way of combining two data sets.
Did you use the "external is keyed" option?
I open the file with the duplicate cases, click on Data --> Merge Files --> Add Variables. Then I pick the other file. In the "Add Variables from" window, I check "Match cases on key variables", "Cases are sorted in order of key variables in both datasets", and "Non-active dataset is keyed table."

The last part, I think, is what you mean by "external is keyed", correct?


TS Contributor
Did you check whether there might be duplicate keys in the other file (the one which was supposed to have no duplicate keys)?

With kind regards