<< Click to Display Table of Contents >> Navigation: User guide > Weighting > Rim weighting |
Rim weighting is used when the targets for all the cells in the weighting matrix are not known; only the targets for each float variable separately. For example if we have two variables of 5 and 7 responses then for target weighting we need to know the targets for all 35 cells in the weight matrix. For rim weighting only the 12 totals are needed.
See the function %RIM for further details.
Weighting procedures can be applied separately to different subsets of the data as in the following example but please remember that each respondent can only have one respondent weight at a time when incrementing a table. This example applies two sets (one for each area) of rim targets using three variables.
start control,
* Rim weight example (rim1.stp)
c=rims.cba,
cep,h,y,
finish control,
start data,
serial number in 6,7,8,
card numbers 1,2, in column 1,
order 1234567890XV,
!
! This example applies rim weighting based
! upon the three variables age, sex and class.
! The rims are applied separately for two
! different areas.
!
! First pick up all variables needed
! for the rim weighting
!
ds $sex=$109/1,2,
xt='Sex of respondent',
x='Sex\Male;Female',
ds $age=$110/1,2,3,
xt='Age of respondent',
x='Age\Young;middle;old',
ds $class=$111/1,2,
xt='Social class of respondent',
x='Social class\ABC1;C2DE',
ds $area=$112/1,2,
xt='Area',
x='Area\North;South',
!
if $sex/b+$age/b+$class/b+$area/b,
el 'Faulty float variables',
!
! The main bulk of the variable
! definitions would be here
!
! ...
!
! Now we increment the tables of actuals
! and set up the remainder of the tables
! needed for the rim weighting using NITB.
!
ds $rimsid=$sex.by.$age,
ds $rimtop=$class,
if $area/1, then,
t #rimac1(f=nptb/dbl)=$rimsid*$rimtop,
t #rimv11(f=nptb/nitb/dbl)=$sex*,
t #rimv21(f=nptb/nitb/dbl)=$age*,
t #rimv31(f=nptb/nitb/dbl)=$class*,
t #rimwt1(f=nptb/nitb/dbl)=$rimsid*$rimtop,
endif,
if $area/2, then,
t #rimac2(f=nptb/dbl)=$rimsid*$rimtop,
t #rimv12(f=nptb/nitb/dbl)=$sex*,
t #rimv22(f=nptb/nitb/dbl)=$age*,
t #rimv32(f=nptb/nitb/dbl)=$class*,
t #rimwt2(f=nptb/nitb/dbl)=$rimsid*$rimtop,
endif,
!
finish data,
start manip,
!
! Set the rim targets.
! In this example the targets are percentages.
!
mt #rimv11=(100,49,51),
mt #rimv21=(100,39,40,21),
mt #rimv31=(100,44.5,55.5),
!
mt #rimv12=(100,50,50),
mt #rimv22=(100,35,41.5,23.5),
mt #rimv32=(100,44.5,55.5),
!
! Calculate the weight factors leaving
! the total for each area unchanged.
!
mt #rimwt1=
%rim(u,#rimac1,#rimv11,#rimv21,#rimv31),
mt #rimwt2=
%rim(u,#rimac2,#rimv12,#rimv22,#rimv32),
!
finish manip,
start tables,
!
! Get the weighting factor from
! the appropriate table
!
ds $rimext=$sex.by.$age.by.$class,
if $area/1,dw $weight=$rimext(#rimwt1),
if $area/2,dw $weight=$rimext(#rimwt2),
select wr $weight,
!
! It is good practice to produce weighted
! tables to check that the weighting has
! been applied correctly
!
f=puc/dpt1,
t #w1(f=dpr1)=$sex*$area,
t #w2(f=dpr1)=$age*$area,
t #w3(f=dpr1)=$class*$area,
f=npuc/dpt0,
!
! The main tables for the run would be here
!
! ...
!
finish tables,
Where both target and rim weights are needed together the target variables should be combined using a matrix definition (.BY.) and used as a single rim.