Session 15 Merging Data in SPSS Survey Training Pack Session 15 Merging Data in SPSS
Side-to-Side Merge Merge Section 0 data and Section 1 data Both from same survey and at Household Level Each dataset has one record per HH Linked by primary key – combination of SITEID, BLOCKID, VILLID, HHID
Open Section 0 data File -> Open -> Data – select file Paste to save syntax
Sort Cases Files should be sorted before merge Data -> Sort Cases Sort by primary key – variables in correct order
Section 1 data Open and sort in the same way Each open file has unique dataset name (for SPSS reference – e.g. dataset1, dataset2, etc.) Commands run on “Active” dataset DATASET ACTIVATE DataSet2
Merge Procedure Move to Section0 dataset Data -> Merge Files -> Add Variables
Match cases on key variable
Syntax for Merge /FILE = * - refers to active dataset
Table Lookup Merge Data files with one-to-many relationship Example – household level data (Section 1) with fertiliser level data Each household can have one or more types of fertiliser (or none)
Fertiliser Level Data Highlighted cases both for same household
Table Lookup Merge Data -> Merge Files -> Add Variables Select File to merge Move key identifiers to Key Variables box
Keyed table “Keyed table” is on “one” side of “one-to-many” relationship
Syntax for Table lookup /TABLE – defines the keyed table
Summary Always merge by key identifier Sort files by key identifier before merge “keyed table” at the “one” side of a one-to-many relationship “many” can also be “none” – e.g. household not using fertiliser Careful interpretation needed – might need to aggregate