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.
Please note these steps require a Displayr license.
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 toolbar menu, select Anything > [Your account name] > Open QScript Editor.
- 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 that you want to merge and 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 mergings that you want to apply, do not select any additional categories and click OK. The script then perform 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 will then be available in all of your documents by selecting Anything > [Your account name] > Open QScript from Displayr Cloud Drive > [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 Variable Set
How to Hide/Unhide Questions with Many Categories
How to Unhide All Hidden Questions
How to Use QScripts in Displayr
How to Create a Custom QScript