Create New Variables - Variables from Merged Categories
This tool automates the process of creating new binary variables based on merged categories in Pick One and Pick One - Multi questions , where the sets of merged categories are to be the same for each question . For example, if you have a battery of 100 11-point scales, and you would like to create variables for the top 4, middle 3, and bottom 4 categories for all of them at once, you can do so using this tool.
Usage
When the tool runs you will be prompted to:
- Choose the number of categories in the questions you want to work with. For example, if you are creating new variables from questions that have 7-point scales, you would choose 7 here.
- Choose the questions that you wish to create new variables for.
- Select the categories you wish to combine.
- Enter a label for the new data.
- If you wish to create additional questions from the same data, repeat the previous two steps.
If any Don't Know style options are identified you will be given the option to remove them.
Example
Consider the following agreement scale, where we want to create new questions for the Top 2 (1, 2), and Bottom 3 (3,4,5) categories.
How to apply this QScript
- Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
- Click on the QScript when it appears in the QScripts and Rules section of the search results.
OR
- Select Automate > Browse Online Library.
- Select this QScript from the list.
Customizing the QScript
This QScript is written in JavaScript and can be customized by copying and modifying the JavaScript.
Customizing QScripts in Q4.11 and more recent versions
- Start typing the name of the QScript into the Search features and data box in the top right of the Q window.
- Hover your mouse over the QScript when it appears in the QScripts and Rules section of the search results.
- Press Edit a Copy (bottom-left corner of the preview).
- Modify the JavaScript (see QScripts for more detail on this).
- Either:
- Run the QScript, by pressing the blue triangle button.
- Save the QScript and run it at a later time, using Automate > Run QScript (Macro) from File.
Customizing QScripts in older versions
JavaScript
includeWeb('QScript Functions for Combining Categories');
applyCustomMerges(true);
See also
- QScript for more general information about QScripts.
- QScript Examples Library for other examples.
- Online JavaScript Libraries for the libraries of functions that can be used when writing QScripts.
- QScript Reference for information about how QScript can manipulate the different elements of a project.
- JavaScript for information about the JavaScript programming language.
- Table JavaScript and Plot JavaScript for tools for using JavaScript to modify the appearance of tables and charts.
Q Technical Reference
Q Technical Reference
Q Technical Reference > Setting Up Data > Creating New Variables
Q Technical Reference > Updating and Automation > Automation Online Library
Q Technical Reference > Updating and Automation > JavaScript > QScript > QScript Examples Library > QScript Online Library