How To Merge Data Files With Inconsistent Variable Names

From Q
Jump to navigation Jump to search

The tools for Merging Data Files by adding cases assume that the variable names in the files are inconsistent. For example, they assume that if age is stored in q1 in one file, the other file will use the exact same Variable Name. Where this is not the case, there are a number of strategies that can be used.

Liaise with the data file provider

Often when data files do not match, it is a result of an error by the person who created the data file. It is often useful to get them to fix the problem, as in addition to solving the problem with the variable names mismatching, they may fix other problems that you have yet to discover at the same time.

Using the GUI

You can use drag and drop to match variables in the Merging Data Files dialog box. Although it can feel painfully slow when there are a large number of variables, provided that you drag multiple variables at the same time, this is often the fastest approach.

Copying and renaming

The basic idea is to rename all the variables in one file to match those in the other.

  1. Import the data file that contains the variables that you wish to rename, selecting No to any questions that you are asked when importing.
  2. In the Variables and Questions tab, select all the variables that you wish to rename.
  3. Right-click and select Copy and Paste Question(s) > Exact Copy.
  4. Press ToTop.png to move the variables to the top.
  5. Rename the variables. If you are good with JavaScript you can do this programmatically, but in most cases manual changing will be easiest and fastest.
  6. Hide the original variables in the data file.
  7. Export as an SPSS data file.
  8. Merge the files.