Adding rim weights

This document describes how to add rim weighting to a QPSMR Insight or CATI project.

The QPSMR Companion has much better weighting facilities which should be used.

Adding variables for the rims

All entries used in rim weighting must be single coded and must include all respondents. New variables will usually be needed which satisfy these conditions.

Where reject categories (for example Don’t know/Not applicable) are present they must be given a target of their own or be combined with another category.  If this cannot be done then they should be excluded from the analysis.

Where multi response questions are to be used they will need to be converted to a set of Yes/No questions.  There is a limit of 10 rim variables, which means that only the most important responses from a large multi can be used.

CL code for the weighting

The weighting is going to be calculated using QPSMR CL code in a file that will normally be called rimwgt.stp.

This file is requested by the tables file (qtf) by inserting a CL syntax for tables stage as the first entry in the list of tables.  The syntax should be as follows -

   [*insert rimwgt.stp]

This will cause the weighting file to be included when the CL set-up file (stp) is created.

This file (rimwgt.stp) should be a text file creted with something like Wordpad and must contain the following -

Definition of side and top variables for the rim tables.  Use the variable with the most responses as the top variable.  If more than two rims are needed then side variables will need to be combined together using .BY. (see examples).  The order of the variables in the .BY. is critical and must match the order used in the %rim statement.

Define the table of actual figures for the full matrix.

Dummy definition of the tables to hold the rim targets and the weights.

FINISH TABLES,

START MANIP,

Set the target values for each rim.  The values are preceded by a total figure that must be the sum of the individual values following it.  These values only give the desired proportions, the final total weighted value is determined by the %rim function.

%RIM command which sets the weights using the actual figures and the targets.  The final desired weighted total is given first, the value U will use the actual unweighted total.

START TABLES,

Set the weight variable to zero to disable any previous weighting and to make sure that any stray records have a weight of zero.

Definition of the variable for the rim table extraction.  This will combine together all the side variables and the top variable using .BY. (see examples). The order of the variables in the .BY. is critical and must match the order used in the %rim statement with the top variable last.

Extract the value from the weigting table into the weight variable.

Tell QPSMR to use the weight.

If more than one set of rim weights is to be applied then the above commands (excluding the start and finish commands) will have to be repeated for each set.  In this case remember to filter the tables so that only relevant questionnaires are included in the tables and to use unique names for each set.  No filtering is needed in the manip stage.

Remember that each individual questionnaire can only have one weight at a time.

Adding weights to the data

If it is necessary to add the weights to the raw data file these can be listed to a .csv file by adding the following line at the end of rimwgt.stp -

listcsv $iobs.$weight,

The weights can then be added using the data hand-over facilities.

Example with two rims

This example shows the complete listing of the file rimwgt.stp for two rims (sex and age) using percentage targets.  The "u" as the first argument to %rim causes the weighted total will be the same as the unweighted total.

ds $rimsid=$sex,

ds $rimtop=$age,

t #rimact(f=nptb/dbl)=$rimsid*$rimtop,

t #rimv01(f=nptb/nitb/dbl)=$sex*,

t #rimv02(f=nptb/nitb/dbl)=$age*,

t #rimwgt(f=nptb/nitb/dbl)=$rimsid*$rimtop,

finish tables,

start manip,

mt #rimv01=(100.0,42.3,57.7),

mt #rimv02=(100.0,31.0,33.4,35.6),

mt #rimwgt=%rim(u,#rimact,#rimv01,#rimv02),

finish manip,

start tables,

dw $weight=0;

ds $rimext=$sex.by.$age,

dw $weight=$rimext(#rimwgt),

select wr $weight,

The number of values set for each rim must be exactly the same as the number of responses in the variable plus a total.  In this example $sex has two responses and $age has three responses.  The total for each rim must be the exact sum of the response targets, in this case 100.0.

Example with three rims

This example shows the complete listing of the file rimwgt.stp for three rims (sex, age and class) using percentage targets. The weighted total will be 1200.

start data,

ds $rimsid=$sex.by.$age,

ds $rimtop=$class,

t #rimact(f=nptb/dbl)=$rimsid*$rimtop,

t #rimv01(f=nptb/nitb/dbl)=$sex*,

t #rimv02(f=nptb/nitb/dbl)=$age*,

t #rimv03(f=nptb/nitb/dbl)=$class*,

t #rimwgt(f=nptb/nitb/dbl)=$rimsid*$rimtop,

finish data,

start manip,

mt #rimv01=(100.0,42.3,57.7),

mt #rimv02=(100.0,31.0,33.4,35.6),

mt #rimv03=(100.0,25.0,21.0,34.0,20.0),

mt #rimwgt=%rim(1200,#rimact,#rimv01,#rimv02,#rimv03),

finish manip,

start tables,

dw $weight=0;

ds $rimext=$sex.by.$age.by.$class,

dw $weight=$rimext(#rimwgt),

select wr $weight,

...

finish tables,

The number of values set for each rim must be exactly the same as the number of responses in the variable plus a total.  In this example $sex has two responses, $age has three responses and $class has four responses.  The total for each rim must be the exact sum of the response targets, in this case 100.0.

Example with four rims

This example shows the complete listing of the file rimwgt.stp for four rims (sex, age, area and class) using actual targets. The weighted total will be 1200.

start data,

ds $rimsid=$sex.by.$age.by.area,

ds $rimtop=$class,

t #rimact(f=nptb/dbl)=$rimsid*$rimtop,

t #rimv01(f=nptb/nitb/dbl)=$sex*,

t #rimv02(f=nptb/nitb/dbl)=$age*,

t #rimv03(f=nptb/nitb/dbl)=$area*,

t #rimv04(f=nptb/nitb/dbl)=$class*,

t #rimwgt(f=nptb/nitb/dbl)=$rimsid*$rimtop,

finish data,

start manip,

mt #rimv01=(1200.0,508.0,692.0),

mt #rimv02=(1200.0,373.0,400.0,427.0),

mt #rimv03=(1200.0,563.0,312.0,325.0),

mt #rimv04=(1200.0,300.0,252.0,408.0,240.0),

mt #rimwgt=%rim(1200,#rimact,#rimv01,#rimv02,#rimv03),

finish manip,

start tables,

dw $weight=0;

ds $rimext=$sex.by.$age.by.$area.by.$class,

dw $weight=$rimext(#rimwgt),

select wr $weight,

...

finish tables,

The number of values set for each rim must be exactly the same as the number of responses in the variable plus a total.  In this example $sex has two responses, $age has three responses, $area has three responses and $class has four responses.  The total for each rim must be the exact sum of the response targets, in this case 1200.0.