How To Band Numeric Variables

From Q
Jump to: navigation, search

Banding refers to the process of turning numeric variables into categorical variables with grouped categories. It is also known as bucketing and binning.

Contents

Example

Banding.png

Method 1: Changing Question Type and merging categories

  1. Create a second version of the question (unless you wish to replace the current question).
  2. Change the Question Type to either Pick One or Pick One - Multi.
  3. Show a SUMMARY table for this question.
  4. Merge the categories on the table.

Automating the process for multiple questions

In situations where you wish to apply the same merging process to multiple questions with the same structure - that is, same Value Labels - you can do this using Modifying Data - Use a Question as a Template for Modifying Other Questions. In other situations, a custom QScript can be the best approach.

Method 2: Histograms

Banded variables are automatically created as a bi-product if you create a Histogram and press Create categories.

Method 3: Recode rules

  1. Use Recode Rules to recode the values in your question so that categories that are to be combined get recoded with the same value.
  2. Right-click on the recoded question and select Insert Variables > JavaScript Formulas > Numeric.
  3. In the Expression box, type the Name of the recoded variable. (The Name is the entry in the left-most column of the Variables and Questions tab.)
  4. Enter an appropriate Name and Label for the new variable.
  5. Click OK.
  6. Click the Values (...) button for the new variable and enter the appropriate Label for each of the values. These values correspond to the categories that you consolidated above.
  7. Click OK.
  8. Change the Question Type of your new question to Pick One or Pick One - Multi.

Method 4: Creating JavaScript Variables

Banding can also be achieved by changing creating A JavaScript Variable. For example, if q2b contains numeric data to be banded, Math.floor(q2b/10) + 1 will create bands from 0 to 9, 10 to 19, etc.

Automating the process for multiple questions

This can be automated using QScript or Use as Template for Replication.

Method 5: Date questions

With date questions, automated banding tools are available within Value Attributes.

Empty categories

The categories that Q shows in Pick One and Pick One - Multi questions are determined by the Value Labels in the underlying data file. For example, if a variable has no values in the range from 10 to 20, then it is not possible within Q to create a 10 to 20 band in such variables. Three solutions to this are to:

  • Grouping variables into a large Pick One - Multi question, such that at least one variable has each of the required categories.
  • Modify the Value Labels in the raw data file.
  • Create Binary Variables representing each category. Where many are required, QScript can be useful.
Personal tools
Namespaces

Variants
Actions
Navigation
Categories
Toolbox