This article describes how to create weights from variable(s) in Displayr. Weighting is a technique for adjusting survey results, aligning them with known population characteristics of the population. For example, if a sample contains 40% males and the population contains 49% males, weighting can be used to correct the data to account for this discrepancy.
 Methods

Additional techniques
 Combining categories in an adjustment variable
 Creating twodimensional weights
 Recomputing weights for each category in a variable (e.g., wavebased weighting)
 Making weights sum to sample size or target values
 Selecting a design weight variable
 Specifying upper and lower bounds for weights & specifying alternative weighting algorithms
 Saving a weight variable
 Using weights created outside of Displayr
 Applying weights
Requirements
 One or more variables in your data set that you want to use as adjustment variables. These variables can be categorical or numeric.
 The targets for each category in the weight variable. These can be percentages, population counts, or a JavaScript formula.
 Nominal or Numeric variables can be used as adjustment variables. You cannot use multichoice variable sets.
 Familiarity with weighting survey data. See: How to Weight a Survey.
Please note these steps require a Displayr license.
Methods
Specifying a single adjustment variable
 In the toolbar, select Anything > Weight.
 Use the Adjustment Variable(s) box menu to select a categorical or numeric variable by which you want to weigh.
 Specify whether your targets are Percentages, Population/Count, or JavaScript Formula (see Making weights sum to sample size or target values).
If your weight targets are: Percentages  When selected, this indicates the target numbers are percentages, and Displayr will ensure the sum of the percentages in the Targets grid adds up to 100%.
 Population/Count  this indicates the target numbers are populations (also known as counts). Displayr will ensure that all weight sets have the same total population targets. If Population/Count are used as targets across multiple adjustment variables, they must all have the same total population/count.

JavaScript Formula  You must set Recompute Weights for a single variable (not the entire dataset), and specify an Adjustment Variable. The two variables must be different.
When selected, you may enter a JavaScript formula that produces different targets for the different date periods of the Recompute variable (or for the different categories, if a Nominal variable set is selected). You must use this if your targets vary by wave, for example. See Using targets based on a JavaScript formula for options.
 Once enabled, click the button to add the new weight to your data set. If the button is greyed out or disabled, check the Weight diagnostics at the bottom right for any errors or issues.
Using targets based on percentages
If your desired targets are 60% Male and 40% Female, you would specify 60 for "Male" and 40 for "Female" as below:
Using targets based on population/count
According to U.S. population estimates, in 2020, there were 162.83 million males and 166.24 million females.
Using targets based on a JavaScript formula
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 five waves, with numeric values 15. The target for "Male" was 1,000 up to Wave 3, when it changed to 1,500 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/Time variable set or a Nominal variable set.
 Date/Time: enter a list that contains a target for every date period. For example, if the date/time variable set represents five months, your list will need five targets:
[1000, 1000, 5000, 1500, 1500]

 Nominal: 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 the above). If the values do not start at 0 or are not contiguous, you must enter a target of '0' for the missed values. For example, if a "Wave" variable had the category values 15, your list would have six items:
[0, 1000, 1000, 1500, 1500, 1500]
Specifying additional adjustment variable(s)
If you want to weight by more than one variable, click the Additional adjustment variable set button and select the desired variable set. When you add a second adjustment variable, Displayr will start using Rim weighting or raking. For example, if you want to not only weight by Gender but also how frequently respondents drink coffee, do the following:
 Click
 Add the desired variable, which in this case is Age:
Weight diagnostics
In the lowerright of the window, additional information about the weight is displayed:
These values are as follows:
 Minimum: Minimum weight value.
 Maximum: Maximum weight value.
 Maximum / Minimum: the ratio between the maximum and the minimum.
 Effective Sample Size: Effective Sample Size (ESS) is an estimate of the sample size required to achieve the same level of precision if that sample was a simple random sample.
Additional techniques
Combining categories in an adjustment variable
You can drag and drop the categories of a variable together to combine them within the weight tool. For example, in the Age variable, if you wanted to combine 18 to 24 with 25 to 29, simply:
 Click the 18 to 24 category
 Drag and drop it on the 25 to 20 category.
Note: Your targets will revert to 0s when you drag and drop one category onto another, so you must specify them again if you haven't already.
Creating twodimensional weights
Additionally, within an adjustment variable in the weighting tool, you can add additional variables to create twodimensional weights. Use the Select Adjustment Variable(s) dropdown to the right of where you selected your adjustment variable.
For example, if you wanted to weight your data according to Income by Gender, you would specify:
Recomputing weights for each category in a variable (e.g., wavebased weighting)
In some cases, you want to calculate a weight based on group membership or time period. For example, in longitudinal or tracking studies, when the data is collected in waves, it may be necessary to recompute the weight for each date period (week, month, etc.). That way, each wave uses the same weighting targets, but each wave's weight is calculated separately.
By default, weights in Displayr are computed for the entire data set. Using the Recompute weight by feature, you can enter the targets that will be used for each wave rather than the total sample. To do this, use a Nominal variable with each "wave" as a category.
As with all Displayr's weighting, the weights are recalculated whenever new data is imported, so this option enables the weighting tool to automatically compute new weights for new waves as they appear in the data.
To recompute weights by category:
 From the Recompute weights for menu, select the grouping variable. In this example, the variable is called Interview Date.
The categories of the variable selected in that box will be used to divide up the cases and the weight will be calculated separately for respondents in each category.
Making weights sum to sample size or target values
When sample size is selected in this dropdown, Displayr will ensure that the final weight produces Weighted Count sizes that sum to the data file's sample size. When target values are selected, the numbers entered as targets are used to produce the final weight, so the total Weighted Count on tables will equal the sum of the population targets entered in the weighting tool.
In this example, the unweighted sample size is 327 but the weight has targets of 162,830,000 for men and 166,240,000 for women, so the sum of the targets in the weighting tool is 329,070,000.
Selecting a design weight variable
Design weights are used to compensate for nonproportional stratification. For example, in a population containing 100,000,000 men and 100,000,000 women, if you used quotas or stratification to achieve a sample of 80 men and 20 women, then a design weight is created to take this nonproportional stratification into account. To learn more about Design Weights, click here.
To use a design weight in Displayr, use the Select Design Weight Variable dropdown box to select the design weight variable in your data set.
Specifying upper and lower bounds for weights & specifying alternative weighting algorithms
On the lower left, the Minimum weight and Maximum weight boxes allow you to specify upper and lower bounds for your weights. This technique is called trimming and is designed to ensure that the weight factors are calculated to within certain bounds. For example, if you don't want weights larger than 3, then set maximum to 3 and minimum to 0. The bounds you set are used during the optimization process and not just on the final result. Given the complex nature of these algorithms, sometimes seemingly sensible bounds may not converge, and you will get an error message to that effect. In this case, you can try another algorithm.
You can also change the algorithm as well. The choices are Linear, Raking, and Logit. The default is Raking. To learn more about how to use trimming and the different algorithms you can read up on How to Improve a Weight and Calibration Weights in our Data Story Guide or click here to watch our weighting webinar.
By default, the controls in this section are greyed out and disabled. To enable them, either select two or more adjustment variables, which enables rim weighting/raking, or select a design weight variable.
Saving a weight variable
Once you have an appropriate weight specified, on the bottomright the + New Weight button becomes active. Pressing this button takes you back to the main interface and you see the weight variable being added (saved) to the Data Sources.
Using weights created outside of Displayr
In addition to building weights in Displayr, you can use weights calculated outside of Displayr. See: How to Use a Weight Created Outside of Displayr for more information.
Applying weights
To apply a variable as a weight:
 Select the object (e.g., page) to be weighted.
 Choose the appropriate weight from Inputs > Filters & Weight > Weight.
Please note these steps require a Displayr license.
Next
If issues arise with using your weight, please see How to Troubleshoot Weights
How To Apply Different Weighting Structures To SubSamples
How to Create a New Variable with Merged/Combined Categories
How to Change Weighting using a Control Box
How to Apply a Weight to a Specific Column Only