This article 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).
Requirements
Two or more data files with different ID variables that you want to merge.
Please note these steps require a Displayr license.
Method
- Import the first file into Displayr.
- From the Data Sources tree, hover over any variable > Plus (+) > Insert Variable(s) > Custom Code > JavaScript - Numeric / JavaScript - Text.
- Select the newvariable and in General tab of the object inspector, fill in the fields as follows and press OK.
- Name: CombinedId (you can use any name)
- Label: Combined ID variable (you can use any label)
- In the Data tab of the object inspector, enter the custom code in the JavaScript Code expression.
-
id1 + " " + id2
(replace the variable names with your names)
-
- Click Calculate.
- Go to Share > Export Data > Download as SPSS File (SAV) and save the file somewhere.
- Repeat the previous steps for the second file.
- Merge the two files in the normal way (see How to Merge Files by Variable (Add New Variables) and How to Merge Files by Case (Add New Cases)).
Next
How to Use JavaScript in Displayr
How to Create a Custom Numeric JavaScript Variable