There are times when the categories in a demographic question are more detailed than the ones you wish to use for your analysis, such as age groups of 18 to 24 and 25 to 29 instead of 18 to 29. It may also be the case that you want to combine or interlock categories from different questions, such as age and gender.
This article describes how to combine categories within and across variables...
...to create a mutually exclusive variable which contains the merged categories:
Requirements
- A Document with a data set.
- At least two nominal variables.
Method - Combine categories within a variable
If you'd like to combine categories within a table or variable, going from a variable containing all categories to one with merged categories:
- Drag your variable from the Data Sources tree to your page. In this example, we will do this for our Age variable.
- Select the row labels you wish to combine, while holding down CTRL, right-click, and and press Combine. First, we will select 18 to 24 and 25 to 29.
- Select Rename in the toolbar. Here, we will enter 18 to 29.
- Repeat steps 2 to 3 until you have the desired categories.
Note: It is important to note that using this method to combine categories only combines them on tables and charts, but does not change the categories in the data which would be used in other analyses.
Method - Combine categories across variables
Next, you can use the following method to create interlocking categories between at least two variables/tables.
1. Hover in the Data Sources tree, and click + > Custom Code > R - Text.
2. Enter paste()
in the R Code editor.
3. Drag the first variable (Gender) from your Data Sources tree so it is positioned inside the code brackets.
4. Enter a comma after this variable label.
5. Drag the second variable (Age) from your Data Sources tree so it is positioned inside the code brackets after the comma.
paste(Gender,Age)
6. OPTIONAL: Repeat steps 3 to 5 if there are further variables.
7. Update Name and Label under General.
8. Change Structure to Nominal: Mutually exclusive categories in the Data tab of the object inspector. You will now have a variable that combines Gender and Age categories together.
Next
How to Band Numeric Variables Using a Table
How to Create New Binary Variable(s)
How to Create a Binary Filter from Selected Data
How to Use Paste Functions to Create Dynamic Text Using R
Understanding Variable Sets Video