<< Click to Display Table of Contents >> Navigation: User guide > Data > Hierarchical records (trailers) |
Sometimes in multi card records, the card type denotes a level within the questionnaire, and there may be more than one card with the same card identifier in a questionnaire. An example is a household survey where each household's data is on card type 1, and each person in the household's data is on card type 2. For each serial identifier, there will be one card type 1, and as many card type 2s as there are people in the household.
The procedure here is similar to that for other non-standard multi card record surveys. A SERIAL command and a CARD NUMBERS command is used, and data reading is handled by a READ command. Each card is placed to its required buffer as it is read, and processed accordingly. Normally in this case when the IDF is generated, and a record is written for each record processed at each level. A variable in the IDF (usually called $level) is used as a level indicator for the IDF records, and tables can be filtered on this variable.
Any accumulated variables for the household should be written to all IDF records for the household using a WRITE BACK command.
For this example the card number is in data location 10,
start control,
c=trailer.cba,
finish control,
start data,
serial number in 4-9,
card numbers /1/,/2/,
dm $cards(2),
x='card found;card 2 found',
dm $level(2),
x='household;person',
di $npers = 0;
xt=’Total number of persons interviewed in household’,
@card1,
read $101-180 erec=@endrec,
if $110/n1, then,
l 'First card not card 1',
goto @card1,
endif,
m $cards/1,
! define household variables from $101-180
...
@card2,
read $201-280 erec=@endrec,
if $210/n2, then,
l 'Subsequent card not card 2',
goto @card2,
endif,
m $cards/2,
zero to finish,
di $npers = $npers + 1,
! define person variables from $201-280
...
dm $level=f,t,
goto @card2,
@endrec,
if $cards/n1, l 'missing card 1',
if $cards/n2, l 'no card 2 found',
! the person records have already been
! written, now we write up the household
! record
write back $npers,
dm $level=t,f,
write,
finish data,