Advanced tables and statistics > Dealing with hierarchical data > clear= on the l statement
 
clear= on the l statement
Note clear= is retained in Quantum for backwards compatibility. When you write new Quantum specifications, handle hierarchical data by using analysis levels. When you do that you do not need to use clear=.
Quick reference
To reset cells in Quantum’s intermediate file when the data contains trailer cards which are not analyzed with levels, type:
clear=logical expression
on the l statement.
When we talked about tabulating data using levels, we said that cells are normally reset in the intermediate file when a new respondent is read in or between reads when the data contains trailer cards. If you are using analysis levels, the time at which these cells are updated can be altered using anlev and uplev. If you are not using levels, you can achieve the same effect using the option:
clear=logical expression
on the l statement. This causes the cells in the intermediate table to be reset only when the given logical expression is true. If you want to reset these cells for each new respondent, rather than for each record or read, enter the option as:
clear=firstread
If we take the axis Sex as we did when we explained analysis levels, you can see that both clear= and anlev produce the same results. If you write the axis as:
l sex;clear=firstread
col 10;Base;Male;Female
and take a household of three men and a woman, the intermediate table reads:
Record 1,
Person 1
– Male
10
 
Person 2
– Male
10
 
Person 3
– Female
11
 
Person 4
– Male
11
Record 2,
Person 1
– Female
01
The first cell of Sex is switched on when a household containing a man is found. It remains on until all data for that household has been processed. If a household also contains a woman, the cell for Female is switched on and is not reset until the next record’s data is read in. If a household contains both men and women, both cells are switched on.
Once the first card of the next record is read, the reserved variable firstread is 1 (true), so both cells are reset to zero ready for the next household.
When axes which use clear are tabulated, the reserved variable lastread can be used in a condition on the tab statement so that the cells in the final table are only incremented when all cards for a respondent have been read.
A major use of this facility is in the production of Penetration or Profile tables on trailer card data. As the trailer cards are read, the intermediate table is updated to build a profile of the respondent. Cells in the printed table are incremented only when all trailer cards for a respondent have been processed.
In the example below two tables are being produced: the first shows the number of products bought, the second shows the number of products bought per respondent. Card 1 contains demographic data and card 2 (a trailer card) gives details of the items bought.
tab items brk
ttlBase = Number of Products Bought by Respondent
tab resps brk;c=lastread
ttlBrands of Product Bought
ttlBase = All Respondents
l brk
col 108;Base;hd=Class;AB;C1;C2;DE
l items
col 210;Base;hd=Brand;A;B;C;D
l resps;clear=firstread.eq.1
col 210;Base;hd=Brand;A;B;C;D
The elements of items and resps are exactly the same: they are the brands bought. The difference is in the l statement which names the axis and defines its conditions. Items is just a straightforward axis whose cells in the intermediate table are reset to zero between reads. Any tables produced with this axis are a count of the number of times each brand was bought by respondents in each class. If the cell created by the intersection of Brand B and Class DE contained the number 52, this would mean that Brand B was bought 52 times by class DE respondents. This might mean that 52 respondents bought that brand once each or that 20 respondents bought it, with some buying it more than once.
Resps, on the other hand, has the condition clear=firstread.eq.1 indicating that cells in the intermediate table should only be reset to zero when a new respondent is reached. This means that these cells contain respondent profiles — that is, they indicate whether or not a respondent bought a particular brand at any time; they will not show the number of times the respondent bought each one.
The tab statement using this axis has the condition c=lastread.eq.1 meaning that the table itself is not to be updated until all data for a respondent has been read. The cells in this table indicate how many respondents in each class bought each brand. This time, if the cell created by the intersection of Brand B and Class DE contains the value 52, it is because 52 class DE respondents bought brand B at least once.
See also
Dealing with hierarchical data