Construct Weight

From Q
Jump to navigation Jump to search
Related Online Training modules
Creating a Weight with 1 Variable
Creating a Weight with 2 Variables
Creating a Weight by Wave
Generally it is best to access online training from within Q by selecting Help > Online Training

(This page describes how to construct weights in versions of Q prior to Q5.13.1.0. Please refer to How to Configure a Weight from Variable(s) in Q for an overview of methods for constructing weights in Q5.13.1.0 and beyond).

To create a weight, go to the Variables and Questions tab, right-click, and select Insert Variable(s) and Weight. This opens the Construct Weight dialog box.

Creating a weight with one variable

Any Pick One question can be used to create a target weight. To create a weight:

  • Go to the Variables and Questions tab, right-click, and select Insert Variable(s) and Weight
  • Select the question that you wish to set targets for from the Target question(s) drop-down menu.
  • Select whether you wish to set targets based on percentages or counts by clicking the buttons for Percentage % or Population/Count in the Target numbers section.
  • Enter the desired targets for each category into the relevant cells in the Targets section.
  • Click OK.

Creating weights with multiple variables

It is also possible to create a weight from a combination of questions. For example if you want to weight by age and gender, then weights need to be set for each combination of categories from your age and gender questions. There are a number of ways to go about this in Q.

If you know which targets you want to set for each category combination (e.g., males 18 to 24), then the weight can be created by selecting multiple questions from the Target questions and Target Column Questions drop-downs in the Weight set section. This will produce a larger number of cells in the Target numbers section – one cell for each combination of categories from the selected questions – into which you can enter the desired targets.

In some cases, appropriate targets for the combinations of categories in the questions that you wish to weight by are not available. Once you have targets entered for a single question according to the method above for Using one variable, press the Add Weight Set button, select a question from the Target questions drop down in the second weight set, and then enter the targets for this question. The weights are computed using Rim Weighting (also known as raking). Q uses a standard Rim Weighting algorithm with 100 iterations.

Sometimes it may be necessary to apply target weights to a number of sub-groups of the sample as well as to the total sample. For example, you may want to separately compute and apply weights to each wave of a tracking study. If this is the case, you can select an appropriate Date or Pick One question from the Recompute for each drop-down. When a Date question is selected, the weighted proportions will be the same in each time period. When a Pick One question is selected, the weighted proportions will be the same when you filter by any of the categories from that question.

Pressing Diagnostics Report will cause Q to check the validity of your weights, inform you of any problems, and present information about the final calculated weights.

You can paste targets that have been copied from Excel using the PasteButton.png button. You can copy the targets by pressing CopyButton.png.

Buttons, Options and Fields

The Construct Weight dialog allows you to construct and edit a weight variable by entering targets for question categories. You can choose multiple questions within a weight set to enter targets for combinations of categories, and you can enter multiple sets of targets via Add Weight Set.


The constructed weight variable may be selected in the Weight drop-down for a table in the Outputs Tab.


As with other Q-constructed variables, the weight variable will be automatically updated if you import a new data file. If any of the target categories change in the new data file, the variable's status will become INVALID until it is fixed.


Recompute for each Select a Date question for the weight to be recomputed for each date period (week, month, etc.). As with all Q's weighting, the weights are recomputed when new data is imported, so this option enables the weighting to automatically compute new weights for new waves. This allows you to enter the targets in terms of each month's sample, rather than the total sample. You may also select a Pick One question if the targets should be recalculated for each its categories (e.g. for each "wave" of a tracking study).


Add Weight Set Adds another weight set to this weight, allowing you to enter seperate targets for another question. Multiple weight sets will be combined using rim/rake weighting to produce the final weight.


Diagnostics Report Check that all entered targets are valid (an error message will be shown if not), and see a diagnostics report to confirm the final weight that Q produces is what you expect.


Weight set

( X ) Remove the weight set.


Target question(s) Select Pick One questions that contain the categories you wish to enter targets for. Select multiple questions to have their categories nested under each other in the rows of the Targets grid.


Target column question(s) Select Pick One questions whose categories you wish to see in the columns of the Targets grid.


Target numbers

Percentage % When selected, this indicates the target numbers are percentages, and Q will ensure the sum of percentages in the Targets grid add up to 100%.


Population/Count When selected, this indicates the target numbers are populations (also known as counts), and Q will ensure that all weight sets have the same total population targets.


JavaScript formula When selected, you may enter a JavaScript formula that produces different targets for the different date periods of the Recompute Question (or for the different categories, if a Pick One question is selected). You need to use this if your targets vary by wave, for example.


Your JavaScript may be one of either:

  • A formula that uses the recompute question values as an input (t), and outputs a number.
    • For example, the recompute question "Wave" has 5 waves, with numeric values 1 - 5. The target for "Male" was 1000 up to wave 3, when it changed to 1500 due to an increased sample. The JavaScript formula for "Male" would be:
      if (t < 3) 1000; else 1500;
  • A list of target numbers, one for each value of the recompute question. The type of list you enter depends on whether your recompute question is a Date question, or a Pick One question.
    • Date: enter a list that contains a target for every date period. For example, if the date question represents 5 months, your list will need 5 targets:
      [1000, 1000, 5000, 1500, 1500]
    • Pick One: enter a list that contains targets for each category's numeric value (the same numbers you see in the Source Values column of Value Attributes), starting from 0 and finishing at the highest value in the data. This will only work when the values are positive whole numbers (otherwise you must use a formula, like above). If the values do not start at 0, or are not contiguous, you must enter a target of '0' for these missed values. For example, if a "Wave" question had the category values 1 - 5, your list would have 6 items:
      [0, 1000, 1000, 1500, 1500, 1500]


Force sum of weights to equal sample size When ticked, Q will ensure that the final weight will produce Population sizes that sum to the data file's sample size. When un-ticked, the target numbers are used literally to produce the final weight, so the total Population on tables will equal the sum of population targets entered here.



The categories from the Target question(s) appear in a grid. The category labels may be dragged on top of each other to merge them, using your mouse. This is useful if you have been given target numbers for combined categories but the data contains un-combined categories.


( Copy ) Copy the target numbers entered below into a format suitable for pasting into Excel.


( Paste ) Paste target numbers that have been copied from Excel into the grid below.