This article describes how to combine two or more variables with the same structure into a single variable set displaying data for each on the same table.
Requirements
- Familiarity with the Structure and Value Attributes of Variable Sets.
- Two or more variables with the same structure that you want to combine into a single variable set.
- Variables' Value Attributes (codes) must be consistent across the variables, that is the Value for each category must be the same. If not, please see Additional details.
Method
1. From the Data Sources tree, select the individual variables that you want to combine by holding down your Ctrl key and selecting each variable. In this example, we've selected a series of brand attitude questions each setup as Nominal: Mutually exclusive categories and each containing the same preference scale.
2. From the toolbar menu, select Combine > As Variable Set > Do Not Merge Variables. If you've already used any of the variables to create tables/outputs in your document, you'll be able to choose one of the following options:
- Change data in all tables and charts - updates existing tables and charts based on the new variable structure.
- Make a copy so existing tables and charts are not affected - which creates a copy of the variables which leaves existing tables and charts unchanged.
A new combined variable set is created. Displayr will automatically work out the appropriate variable set structure and name based on the input variables. If Displayr AI is enabled, a sensible set name will be created. Otherwise, matching text will become the set name, see here for more details. In the example, above, since we using nominal variables as inputs, Displayr creates a variable set with the structure Nominal - Multi: Grid with unordered categories and names it q4 using the non-AI naming method.
3. OPTIONAL: To rename, right-click on the variable set name (q4 in the above example) and select Rename.
Additional details
When combining categorical variables together in a set, the categories in the final set are labeled based on the values of the categories across all the variables. If your variables don't have consistent values across them, you will need to recode them to be the same. For example, if one of the brands above had the reverse values for the scale, you would need to change the values to be consistent with the other brands. To do so:
- In the Data Sources tree, select the variable to recode.
- In the object inspector, click Value or Select categories to pull up the Value Attributes.
- Change the Value column to what value should correspond to the category in the final set and click OK.
- Repeat this recode process for all variables until they are consistent.
- Displayr uses the Value from the original raw data to set the categories in the combined set. You will need to essentially hardcode this value into a new variable to use in the final set using a JavaScript variable. Create a new JavaScript-Numeric variable in the Data Set and in the Expression simply put in the Name of the first variable you recoded.
- Change the Label of the variable to correspond.
- If there are more variables to hardcode like this, you can Duplicate the JavaScript variable and modify the Expression and Label as needed.
- Select all the variables with the consistent codes in the Data Sources tree.
- From the toolbar menu, select Combine > As Variable Set > Do Not Merge Variables.
- You should click on the Values or Select Categories on the final variable set to confirm that the Values and Categories are what you expect and to refine any category labeling.