Category:Creating New Variables
Questions and variables can be created and modified on the Variables and Questions tab (and also by selecting Create > Variables and Questions from the Tables/Outputs Tab).
In most data analysis programs, new variables are created by either creating mathematical expressions, such as q4 + q5, or by recoding into new variables. While these approaches are also available in Q, Q also has a variety of other tools which are, for most problems, superior.
Modifying existing data
Related Online Training modules | |
---|---|
Creating NETs | |
Generally it is best to access online training from within Q by selecting Help > Online Training |
In Q it is possible to achieve many results that are ordinarily computed by creating variables in other programs by:
- Modifying the Question Type of data (see Setting and Changing Question Types)..
- Changing Value Attributes.
- Merging categories on tables, programs.
- Manually edited on the Data tab. For example, individual values can be changed and observations can be deleted. This does not cause the raw data to change. However, any changes made on the Data tab flow through to all analyses that use the data.
For example, this is usually the fastest way to compute things like::
- Top 2 Box Scores.
- Shares from numeric data (see How to Compute Share of Wallet, Spend, Mouth, etc. (i.e., Volumetric Analysis)).
- NPS Scores.
- NETs.
Duplicating and modifying variables and questions
Sometimes modifying a question is not desirable, as the original question is useful in its own right. In this situation:
- Duplicate the existing variable or set of variables (see Copy and Paste Variables and Questions).
- Modify the duplicated data.
Coding
Coding is often the most efficient way to create new variables where the variables need to reflect a categorization of a large number of categories. It is principally designed for text data.
Logic variables
Logic Variables are a relatively simple type of variable used when creating custom categories in a Banner, such as segments, lifestage, or other categories that are constructed using one or more inputs.
Binary - Complicated variables
When a Filter is created, Q automatically creates a binary variable. This is usually the best way to construct variables requiring boolean logic. See Filters and Creating Binary Variables.
Ready-Made Formula(s)
The Ready-Made Formula(s) Menu contains various automated routines for:
- Computing the most common mathematical functions: Sum, Minimum, Maximum, Average, Standard Deviation, Variance, Count, Any of and None of. Select the data in the Variables and Questions tab and select Insert Ready-Made Formula(s) > Mathematical Functions (by Case).
- Automatically combining different questions, such as merging them and creating new questions with all |combinations of the input questions.
- Restructuring data (e.g., converting multiple binary variables into a categorical variable).
QScripts in the Online Library
Many standard problems can be solved using Automate > Online Library and searching for specific QScripts. For example: And, they can be created using the Online Library (Tools > QScripts: Online Library and locate the script in the menu):
- Create New Variables - Top 2 Category Variable(s) (Top 2 Boxes)
- Create New Variables - Recode Net Promoter Score (NPS) Variable(s)
- Create New Variables - Numeric Variable(s) from Code/Category Midpoints
- Filtering - Filters from Selected Data
Creating variables by mathematical expression
Related Online Training modules | |
---|---|
Excel-Style Formulas | |
Simple JavaScript Formulas | |
JavaScript If Statements | |
Generally it is best to access online training from within Q by selecting Help > Online Training |
There are two ways of creating variables from scratch (i.e., by typing an expression, such as q1 + q5). The most general and powerful way is to create a JavaScript Variable. A simpler method, which is considerably less flexible, is to use Excel-Style Formulas.
Creating new variables by writing your own QScript
You can also do the entire process of creating variables by writing code (i.e., QScript). Please keep in mind that while in many products this is the smart way of working, in Q this approach is only best practice when you are wanting to automate the process. For example, if you need to automatically create 1,000 new variables, then this approach may make sense, although there will often be faster and easier options.
Adding variables created in other programs
See Merging Data Files and Paste Data (e.g. From Excel).
See also
Pages in category 'Creating New Variables'
The following 71 pages are in this category, out of 71 total.
C
- Complicated Changes to Question Types
- Construct Logic Variable
- Create New Variables - Automatically Combine Categories - By Geography - Australia - To Local Government Areas (LGAs)
- Create New Variables - Automatically Combine Categories - By Geography - Australia - To States
- Create New Variables - Automatically Combine Categories - By Geography - Australia and New Zealand - To Local Government Areas (LGAs)
- Create New Variables - Automatically Combine Categories - By Geography - Australia and New Zealand - To States/Regions
- Create New Variables - Automatically Combine Categories - By Geography - Canada - To Provinces
- Create New Variables - Automatically Combine Categories - By Geography - Canada - To Regions
- Create New Variables - Automatically Combine Categories - By Geography - Europe (including UK) - To Communites/Districts
- Create New Variables - Automatically Combine Categories - By Geography - Europe (including UK) - To Provinces/Counties
- Create New Variables - Automatically Combine Categories - By Geography - Europe (including UK) - To States/Regions
- Create New Variables - Automatically Combine Categories - By Geography - Europe - To Communities
- Create New Variables - Automatically Combine Categories - By Geography - Europe - To Provinces
- Create New Variables - Automatically Combine Categories - By Geography - Europe - To States
- Create New Variables - Automatically Combine Categories - By Geography - New Zealand - To Local Government Areas (LGAs)
- Create New Variables - Automatically Combine Categories - By Geography - New Zealand - To Regions
- Create New Variables - Automatically Combine Categories - By Geography - United Kingdom - To Counties
- Create New Variables - Automatically Combine Categories - By Geography - United Kingdom - To Countries
- Create New Variables - Automatically Combine Categories - By Geography - United Kingdom - To Districts
- Create New Variables - Automatically Combine Categories - By Geography - United Kingdom - To Regions
- Create New Variables - Automatically Combine Categories - By Geography - United States - To Counties
- Create New Variables - Automatically Combine Categories - By Geography - United States - To Regions
- Create New Variables - Automatically Combine Categories - By Geography - United States - To States
- Create New Variables - Automatically Combine Categories - By Geography - United States and Canada - To Countries
- Create New Variables - Automatically Combine Categories - By Geography - United States and Canada - To Regions
- Create New Variables - Automatically Combine Categories - By Geography - United States and Canada - To States/Provinces
- Create New Variables - Automatically Combine Categories - By Pattern (CHAID) - Adjacent Categories
- Create New Variables - Automatically Combine Categories - By Pattern (CHAID) - Adjacent Categories Unless Missing Value Code
- Create New Variables - Automatically Combine Categories - By Pattern (CHAID) - Any Categories
- Create New Variables - Automatically Combine Categories - By Value - Custom Categories
- Create New Variables - Automatically Combine Categories - By Value - Equally Spaced Categories
- Create New Variables - Automatically Combine Categories - By Value - Percentiles
- Create New Variables - Automatically Combine Categories - By Value - Tidy Categories
- Create New Variables - Binary Variable(s)
- Create New Variables - Contrast Periods
- Create New Variables - Duplicates
- Create New Variables - Log Transform Variable(s)
- Create New Variables - Scale Variable(s) - Center Within Case
- Create New Variables - Scale Variable(s) - Center Within Variable
- Create New Variables - Scale Variable(s) - Ranks Within Case
- Create New Variables - Scale Variable(s) - Ranks Within Variable
- Create New Variables - Scale Variable(s) - Standardize Within Case
- Create New Variables - Scale Variable(s) - Standardize Within Variable
- Create New Variables - Scale Variable(s) - Unit Interval Within Case
- Create New Variables - Scale Variable(s) - Unit Interval Within Variable
- Create New Variables - Square-Root Variable(s)
- Creating A Crosstab In JavaScript
- Creating Binary Variables
- Creating Categorical Variables
- Creating Date Variables
- Creating Numeric Variables
- Creating Text Variables
H
- How to Add a None of These
- How To Band Numeric Variables
- How To Compute Percentiles
- How to Compute Share of Wallet, Spend, Mouth, etc. (i.e., Volumetric Analysis)
- How to Compute Statistics for Variables (e.g., Average, Maximum, Number of Responses)
- How to Conditionally Recode into a New Variable
- How To Convert Binary Variables Into Max-Multi Format
- How To Count The Number Of Responses
- How to Create a Categorical Variable from Binary Variables
- How To Create New Variables With Multiple Categories
- How To Merge Categories
- How to Recode Into a New Variable
- How To Test Differences in % Column Shares
- How to Use Search/Replace to Conditionally Recode Lots of Variables