Advanced tables and statistics > Dealing with hierarchical data > Analysis levels > Naming levels in the edit section
 
Naming levels in the edit section
Quick reference
To start the edit in a levels job, type:
ed level_name
To start edits for other levels, type:
level level_name
To define statements to be executed at the end of a level, type:
endlevel level_name
Terminate the edit for each level with:
return
More information
When analysis levels are used, all editing must be done by level. Edits start with the statement:
ed level_name
where level_name is the name of the level to be edited, and end with a return. Subsequent edits for other levels start with:
level level_name
and end with return. The edit section as a whole is terminated with an end statement:
ed hhold
/* Edit statements for household data
return
level person
/* Edit statements for person data
return
end
All statements between an ed or level and a return are executed after the cards for a given level have been read into the C array. So, if the current level contains two cards of the same type, all statements for that level are executed twice, but if the cards are of different types, the statements are executed once only.
Where it is necessary to perform a task after all data at a given level has been read in for the current record, you must enter the edit statements preceded by the statement:
endlevel level_name
and followed by a return. This causes all statements up until the return to be executed once when all data for the named level has been read in. In the example this would be when the third card 2 had been read. Note, however, that if the level in question contains data at higher levels the statements following endlevel will not be processed until all data at the lower levels has been read. For example:
ed hhold
/* ptot counts number of people in household
/* amount accumulates total family income
ptot=0; amount=0
return
level person
ptot=ptot+1
/* Personal income is in C(232,235)
amount=amount+c(232,235)
return
endlevel hhold
/* Calculate average family income
amount=amount / ptot
return
end
In this example, the statements between level person and return are repeated for each person. The statements following endlevel are not processed until the data for the last person in the household has been read.
See also
Analysis levels