%RIM

<< Click to Display Table of Contents >>

Navigation:  Reference > Functions >

%RIM

This function computes factors which weight data to targets, where the full distribution within the target matrix is unknown: only the target totals for each dimension of the matrix are defined. A maximum of 100 dimensions is allowed.

The RIM function may only be used in a Manip Stage.

Form of use:

MT #rimwgt = %RIM (wconstant,#rimact,#rimv,#rimv ...),

The wconstant is the desired final weighted total. If U (undefined) is specified, then the actual total will be used - the weighted total will be the same as the unweighted total.

#rimact is a table containing the actual unweighted figures for each cell in the full matrix. It should have been incremented in a previous stage.

#rimv are tables containing target totals for each dimension. Each table must have the same number of rows (excluding total row) as the number of elements in this dimension. As a check, a warning is given if the total row does not contain the sum of the other rows. The sizes of these tables (excluding totals) multiplied together must equal the number of cells in #rimact.

#rimwgt is set to the weight factors for each cell in the matrix.

Because the desired weighted total has already been given in wconstant, the figures in #rimv specify the ratios of the weighted figures, not the weighted targets themselves. This means that all the figures from each table will be scaled up or down so that the sum of them becomes the same as wconstant. This allows various types of target to be used, including percentages.

A maximum of 100 rims is allowed although more than 20 will produce enormous tables.

All tables used in %rim must be double precision.

Because the desired weighted total has already been given in $wconstant, the figures in each rim table specify the distribution of the weighted figures, not the weighted targets themselves. This means that all the figures from each rim table will be scaled up or down so that the sum of them becomes the same as wconstant. This allows various types of rim targets to be used including percentages and population.

Rim weight example (1):

start data,

! example of rim weighting using sex and age

! weighted total will be 1500

ds $sex=...

ds $age=...

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 data,

start manip,

mt #rimv01=(100.0, 42.0, 58.0),

mt #rimv02=(100.0, 31.0, 33.0, 36.0),

mt #rimwgt=

%rim(1500.0,#rimact,#rimv01,#rimv02), 

finish manip,

start tables,

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

dw $wt=$rimext (#rimwgt),

select wr $wt,

...

finish tables,

Rim weight example (2):

start data,

! example of rim weighting using

! sex, age and class.

! weighted total will be same

! as unweighted total.

ds $sex=...

ds $age=...

ds $class=...

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.0, 58.0),

mt #rimv02=(100.0, 31.0, 33.0, 36.0),

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

mt #rimwgt=

%rim(u,#rimact,#rimv01,#rimv02,#rimv03), 

finish manip,

start tables,

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

dw $wt=$rimext (#rimwgt),

select wr $wt,

...

finish tables,

The individual targets can have different totals, CL will rebalance each set of rim targets to the wanted total so the previous manip stage could have read:

start manip,

mt #rimv01=(2500.0, 1050.0, 1450.0),

mt #rimv02=(2500.0, 775.0, 825.0, 900.0),

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

mt #rimwgt=

%rim(2500.0,#rimact,#rimv01,#rimv02,#rimv03), 

finish manip,