0
votes

I'm currently busy combining two datasets in SPSS, but it's not the usual problem, after come (crafty) manipulations I've managed to bring it down to:

-Dataset I: non-unique ID 'A'

-Dataset II: unique ID 'B'

I want keep dataset I and add to the data from B from dataset II for each row where A matches B to the each A.

So: dataset I contains a person's ID and a disease in each row (multiple diseases possible, hence non-unique ID) & dataset II contains a person's ID and address line (unique). I want to merge those so that each ID + disease gets updated with the address if that is available.

Next to this, I'd like to accomplish keeping the rows from I where A has no matching B in II and; add new cases to keep the rows from II where B did not match any A.

Would something like this be possible using SPSS?

1

1 Answers

0
votes

See MATCH command and also this example.

Something like this should work (ensuring ID variables from each dataset have a common name, in this example simply "ID"):

DATASET ACTIVATE DS1.
SORT CASES BY ID.
DATASET ACTIVATE DS2.
SORT CASES BY ID.
DATASET ACTIVATE DS1.

MATCH FILES FILE=* /TABLE=DS1 /BY ID.