Weight Data in a Wrangle
Survey samples rarely match the population perfectly. Maybe younger people were keener to respond, or one region is over-represented. Weighting corrects for that: each record gets a weight factor, so that when you analyze the data, groups count in the right proportions.
The Weighting step in a wrangle calculates those weight factors and writes them to a new variable. You then apply the weight in Data Explorer.
Understanding weighting
Section titled “Understanding weighting”Weight factor: a number for each record. A record with a weight of 2 counts twice; one with 0.5 counts half.
Simple weighting: weighting on one variable, such as gender.
RIM weighting: weighting on several variables at once, such as gender, age group and region. Data Wrangler adjusts the weights until every variable matches its targets together.
Targets: the proportions you want each code to make up, as percentages. Each variable’s targets must add up to 100%.
Weight Definition: a saved set of targets that you, and other weighting steps, can use again. Data Wrangler stores each one in a Weighting Index data store.
Weighting variables need codeframes, because you set a target for each code.
Add a Weighting step
Section titled “Add a Weighting step”- Add the step - Drag Weighting from MICROSERVICES onto the canvas, between your Reader and Writer, and connect it. See Build a wrangle.
- Click the step - Its settings open below the canvas.
- Click ADD WEIGHTING FUNCTION - The Weighting Your Data dialog opens. Work through it with NEXT and BACK, as below.
Set up a weighting function
Section titled “Set up a weighting function”- Name the weight variable - Choose Create New Variable and enter a Variable Name and Variable Label. Data Wrangler adds
_weightedto the end of both, sowtbecomeswt_weighted. Don’t add it yourself. - Choose the variables to weight on - Move them from Available Fields to Selected Fields. Only variables with codeframes are listed. Choose one for simple weighting, or more for RIM weighting; the next screen confirms which you’ll get.
- Filter if you need to - Optionally, use the filter builder to apply different targets to different groups, for example separate age targets for each country. Otherwise, skip this step.
- Choose Create New Weight Definition - Or Use Existing Weight Definition to reuse targets you’ve saved before. See Reuse a Weight Definition.
- Enter your targets - Type a Target % for each code. The Current Total for each variable must reach 100%.
- Save the definition, if you’ll want it again - Tick Save Weight Definition to apply in other Weighting operations in future. You’ll need this ticked to recalculate on a schedule.
- Click NEXT to finish - The function appears in the WEIGHTING FUNCTIONS table.
To change a function, click its edit icon in the table. To remove it, click delete and confirm.
Write to the same weight variable more than once
Section titled “Write to the same weight variable more than once”When the step already has a function, you can choose Use Existing Variable on the first screen. Use this with filters, for example one function per country, all writing to the same _weighted variable.
Reuse a Weight Definition
Section titled “Reuse a Weight Definition”If you, or someone with access, has saved a Weight Definition, choose Use Existing Weight Definition at step 4. Pick the Weighting Index data store that holds it. If your variables are named differently from the ones in the saved definition, you’ll be asked to pair them up and click Add after each pair.
Weighting Index data stores are created when you publish a wrangle with Save Weight Definition… ticked. They’re named after the wrangle and function, for example ACME wave 3_func1_index.
Recalculate on a schedule
Section titled “Recalculate on a schedule”At the bottom of the step’s settings, Calculate Weight Factors has two options:
- Once Only: the weights aren’t recalculated on a schedule.
- Schedule Recalculation: the targets are reapplied on a schedule, so weights keep up as new records arrive. Click the clock icon to open Set Update Frequency and set the schedule.
Schedule Recalculation is only available when every function uses Create New Weight Definition with Save Weight Definition… ticked. Hover over the option to see why it’s turned off.
This schedule only decides when the weights are recalculated during a run. It doesn’t start runs itself; for that, schedule the wrangle.
Use the weights
Section titled “Use the weights”Publish the wrangle, then open the output data store in Data Explorer and apply your _weighted variable with Apply Weights.
Records with a blank in any of the weighting variables don’t get a weight.
Frequently Asked Questions
Section titled “Frequently Asked Questions”What’s the difference between simple and RIM weighting?
Simple weighting uses one variable. RIM weighting balances several variables at once. Data Wrangler picks the method from how many variables you choose.
Why can’t I see my variable in Available Fields?
Only variables with a codeframe are listed, and multi-response variables aren’t. Add a codeframe to the variable in the source data store first. See Codeframes.
Why can’t I choose Schedule Recalculation?
Every function in the step must use Create New Weight Definition with Save Weight Definition to apply in other Weighting operations in future ticked.
Do I need to name my variable with _weighted?
No. Data Wrangler adds _weighted for you, which is what Data Explorer looks for.
Can I set different targets for different groups?
Yes. Use the filter step in Weighting Your Data, with one function per group, all writing to the same weight variable.
Common Issues and Solutions
Section titled “Common Issues and Solutions””The total percentage of the variable(s) listed below does not equal 100%.”
Section titled “”The total percentage of the variable(s) listed below does not equal 100%.””One or more variables’ targets don’t add up to 100%.
- Check each Current Total - Totals that aren’t 100% are shown in red.
- Adjust the targets - Change the Target % values until each total is exactly 100%.
”Please provide at least 1 weighting function.”
Section titled “”Please provide at least 1 weighting function.””The Weighting step doesn’t have a function yet. You’ll see this when you publish.
- Add a function - Click ADD WEIGHTING FUNCTION and work through the dialog.
”Scheduled recalculation has been enabled but no schedule has been applied.”
Section titled “”Scheduled recalculation has been enabled but no schedule has been applied.””You chose Schedule Recalculation but didn’t set a schedule.
- Set the schedule - Click the clock icon next to Schedule Recalculation, set the frequency and save.
- Or choose Once Only - If you don’t need regular recalculation.