Category:Creating New Variables

From Q
Jump to navigation Jump to search

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:

For example, this is usually the fastest way to compute things like::

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:

  1. Duplicate the existing variable or set of variables (see Copy and Paste Variables and Questions).
  2. 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:

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):

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

Subcategories

This category has only the following subcategory.

9

Pages in category 'Creating New Variables'

The following 71 pages are in this category, out of 71 total.

C