Data editing > How Quantum reads data > Trailer cards
 
Trailer cards
By using the Levels facility, the user need not know how Quantum deals with trailer card data internally. However, there are occasions when it may be necessary to edit or tabulate the data without using levels. To do this, it is necessary to know more about how trailer cards are processed.
Quantum deals with trailer cards in a number of ‘reads’. Cards are read into the appropriate rows of the C array until:
a card is located with a card type matching that of the previous card (for example, two consecutive card 2’s)
or
a card is read with a type lower than its predecessor and matching one of the card types already read in during the current ‘read’ (for example, a card 2, a card 3, and then another card 2).
To produce useful tables, you need to know which cards are currently in the C array.
Variables for tracking cards
Quantum has four reserved variables (thisread, allread, firstread and lastread) which it uses to keep track of which cards it has read for each respondent.
thisread
The array called thisread is used to check which cards have been read in during the current read. thisread1 will be true (or 1) if a card type 1 has just been read in; thisread2 will be true if a card 2 has just been read, and so on.
There are nine such variables (thisread1 to thisread9) available unless extra card types have been specified using the max= option In this case, these variables will be numbered 1 to max; if there are 13 cards, you will have thisread1 to thisread13. For further details on max=, see Highest card type number.
allread
allread notes which cards have been read in so far for this questionnaire. If cards 1, 2 and 3 have been read so far, allread1, allread2 and allread3 will all be true. Additionally, each cell of allread will contain the number of cards of the given type read in — for example, if two cards of type 3 have been read, allread3 will be true and it will contain the number 2.
There are nine allread variables available unless extra card types have been specified with max=.
firstread and lastread
The variables firstread and lastread become true when the first and last cards in a record have been read in.
Examples
You can use these variables in your program to associate specific parts of the edit or tabulation section with specific types of data. For example:
if (.not. thisread3) go to 400
* card 3 edit follows
     .
     .
400 continue
/* calculate average when all cards read for respondent
if (lastread) average=sum / num
     .
/* update table when all cards read for this respondent
tab brand demo;c=lastread
For example, look at the contents of the C array and the values of thisread, allread, firstread and lastread. Suppose the record has five cards: 1, 2, 2, 2 and 3 of 80 columns each. The first ‘read’ places card 1 in c(101,180) and the first card 2 in c(201,280). The second card 2 is not read into the array yet because it has the same card type as the previous card. As this is the start of a new respondent, firstread is true (or 1), and because cards 1 and 2 have been read, thisread1, thisread2, allread1 and allread2 are also true.
The second ‘read’ deals only with the second card 2 since it is followed by another card of the same type. thisread2 is true, as are allread1 and allread2. Also, allread2 contains the value 2 because you have read in 2 card 2s so far. Note that thisread1 is now false (or 0) as no card 1 was read this time.
On the third and final ‘read’ the third card 2 is read into c(201,280) and card 3 is copied into c(301,380). lastread is true because you have reached the end of the record, thisread2 and thisread3 are true because you have just read cards 2 and 3, and allread1, allread2 and allread3 are true because this record contains cards 1, 2 and 3. allread2 now contains the value 3 because there were 3 card 2s altogether.
The chart below summarizes the cards read and the variables which will be true after each read.
 
c(101,180)
c(201,280)
c(301,380)
thisread
allread
firstread
lastread
Read 1
Card 1
Card 2a
 
12
12
1
 
Read 2
 
Card 2b
 
2
12
 
 
Read 3
 
Card 2c
Card 3
23
123
 
1
If Quantum reads a record in which the repeated cards are out of sequence, it inserts blanks cards of the appropriate types wherever necessary to force the cards into the correct sequence. For example, if the record contains the cards 1, 2, 4, 3, 4, 4 in that order, Quantum generates a completely blank card 3 when it reads the first card 4. The record is then processed as if it contained cards 1, 2, 3, 4, 3, 4, 4.
See also
How Quantum reads data