How To Merge Files Using Two ID Variables

From Q
Jump to navigation Jump to search

This page describes how to merge data files when each file needs to be merged using two different variables (e.g., a respondent ID variable and an observation number).

  1. Import the first file into Q as follows: File > Data Sets > Add to Project, select the source, and choose Use original data file structure and press OK.
  2. Create > Variables and Questions > Variable(s) > JavaScript Formula > Text, filling in the fields as follows and press OK.
    • Name: CombinedId (you can use any name)
    • Label: Combined ID variable (you can use any label)
    • Expression: id1 + " " + id2 (replace the variable names with your names)
  3. Tools > Save data as SPSS/CSV file, and save the file somewhere.
  4. Repeat the previous steps for the second file.
  5. Merge the two files in the normal way (see Merging Data Files).