Advanced tables and statistics > Dealing with hierarchical data > Analysis levels > Defining levels using a levels file
 
Defining levels using a levels file
Quick reference
To define the top level, type:
level_name cards=card_num1[r][, card_num2[r], ... ]
Cards which must be present in every record must have the card number followed by the letter r.
To define subsidiary levels, type:
level_name [cards=card_numbers ] < parent_level
More information
Levels and where to find the relevant data are defined in the levels file which must be created in the same place as your Quantum program file. Levels must be defined in order of priority, with the highest level first. The top level is specified as follows:
levelname cards=n1, n2, ...
where n1 and n2 are the cards containing data for this level. If any of the cards are mandatory, you must follow the card type with the letter ‘r’. Suppose the top level is the whole household, called hhold, and the data for this level is stored on cards 1 and 2, both of which are mandatory. Write:
hhold cards=1r,2r
The second level is defined in much the same way, except that you also have to show that it is a sub-level of the top level. This is done by following the last card number with a less than sign (<) and the name of the parent level. If the second level refers to the individual people in the household, write:
person cards=3 <hhold
From this, you can see that data for each person in the household is on card type 3. If there is more than one person in the household, there is a card 3 for each person.
If the data for a sub-level is on the same card as its parent level there is no need to enter the card specification. Thus, the statement:
trip <person
indicates that information about journeys made is a sub-level of each person’s data but does not have a card of its own: it is all on card type 3.
You must always define the parent level before you define the sub-level. For example, before you define trip as a sub-level of person, you must define the person level.
Any level can contain more than one sub-level of the same importance in the overall hierarchy. Suppose you also have a card 5 for each pet present in the household: this is a sub-level of the top level since the pet belongs to the household as a whole rather than to an individual, so you write:
pet cards=5 <hhold
See also
Analysis levels