Advanced tables and statistics > Dealing with hierarchical data > Analysis levels > Defining the data structure in the levels file
 
Defining the data structure in the levels file
Quick reference
To define the data structure of records in the data file, type:
ser=start_pos, end_pos
crd=start_pos[, end_pos]
max=highest_card_number
reclen=num_cols
maxsub=max_cards_per_level
More information
In addition to defining levels, the levels file also describes the format of the data to be read, thus making the struct statement redundant when you are using analysis levels. All descriptions of data must precede the levels specifications.
The serial number field is identified with the statement:
ser=m,n
where m and n are column numbers without a preceding c. For example, if the serial number is in columns 1 to 5 of each card, write:
ser=1,5
The position of the card type is noted in a similar manner with the statement:
crd=n        or         crd=m,n
For example:
crd=6      or      crd=79,80
If each record contains more than nine cards, you must also enter the number of the highest card type as follows:
max=n
Thus, if the highest card type is 15, write max=15.
If your data file contains records which are longer than 100 columns, include the statement:
reclen=length
in the levels file, where length is the record length.
Quantum assumes that each respondent’s record will contain a maximum of 4096 sub-records or cards. If any of your records contain more cards than this, you must extend the default by entering the statement:
maxsub=n
in the levels file, where n is the maximum number of sub-records (cards) per record. If a record is found with more than the given number of cards, the datapass terminates and messages are written to out2 and the log file.
The theoretical maximum number of sub-records per record is 2,147,483,647, but the actual limit will depend on the amount of memory space available to the datapass program.
Here is an example of a levels file:
ser=1,4
crd=5,6
hhold cards=1r
person cards=2r <hhold
purch cards=3 <person
This example defines records with a serial number in columns 1 to 4 and a card type in columns 5 and 6. Each record can contain data at up to three levels. The highest level is the household (hhold) which is read from card 1 which is mandatory. The second level is person on a mandatory card 2 which is a sub-level of household. The lowest level is the purchase (purch) which is a sub-level of person. Data for this level is read from an optional card 3.
See also
Analysis levels