This article describes how to use a QScript to automatically create new variables based on merged categories in Nominal and Nominal - Multi variable sets.
For example, consider the following Nominal - Multi variable set which asks likelihood to recommend certain brands and for which you want to create a Top 2 Box (Promoters) variable for each of the brands all at once:
The QScript can create new top 2 box variables for each brand:
Before running the QScript, we would check the Value Attributes which show the following values:
This lets us see how the category labels match up to the source values in the data.
Requirements
A Displayr Enterprise user license, which includes the ability to add custom analysis menu items and QScripts. See How to Use QScripts in Displayr for more details.
Method
To run the QScript:
- From the Data Sources tree, select the variable or variable set containing the category or categories that you want to merge.
- From the Data Sources tree, select + > Custom Code> QScript > New.
-
Paste the following code into the QScript editor:
includeWeb('QScript Functions for Combining Categories'); applyCustomMerges(true); - Click the Play button in the QScript Editor toolbar to run the QScript.
- A list of categories will be displayed. Select the first set of categories you want to merge, then click OK. To work out which values you want to use, look at the value attributes for that variable set, and check the Source values.
- Enter a label for the merged category.
- Repeat the previous two steps to select the next categories to merge. If you have already entered all the mergers you want to apply, do not select any additional categories, then click OK. The script then performs the selected category merges.
- If you want to save the QScript for future use, click OK, then enter a file name for the QScript and click OK. This will save the QScript to your Displayr cloud drive and make it available in all your documents by going to Data Sources tree, selecting + > Custom Code> QScript> Open> [QScript Name]. If you don't wish to save the QScript to the cloud drive, click Cancel in the QScript Editor.
Next
How to Add Variable Names and Values to Labels
How to Hide a Category in a Pick One Question
How to Hide/Unhide Questions with Many Categories
How to Unhide All Hidden Questions
UPCOMING WEBINAR: The Roadmap for Market Researchers in the Age of AI