Advanced tables and statistics > Dealing with hierarchical data > Analysis levels > uplev and levbase
 
uplev and levbase
uplev= is an alternative to celllev for creating tables at a higher level than the axes in the table. However sometimes uplev= can give misleading results. Use it only in new Quantum specifications when you need to use levbase to increment the base for every record containing data at the higher level, regardless of whether it contains data at the lower level. However uplev= without levbase is retained in Quantum for backwards compatibility and is therefore documented here in full.
For more information about why uplev= can give misleading results, see Why celllev is preferable to uplev.
Quick reference
To specify a lower level for an axis in a table that is created at a higher level, type:
uplev=level_name
on the l statement.
To increment the base of an uplev’d axis for every record containing data at the higher level, type:
levbase
as an option on the base element.
More information
The way uplev= works is different from the way celllev works. With celllev, you use anlev= on the l and tab statements to specify the update level for the axes and you put celllev on the tab statement to specify the higher level at which you want to run the table. With uplev=, however, you use anlev= on l and tab statements to specify the level at which you want to create the table, and you put uplev= on the l statement to specify a lower update level for the axis.
For example, suppose you want to know how many households in each region contain people in specific age groups. You need to create the table at household level because it is a count of households, but age is a person level axis. So you put anlev=hhold on the tab and l statements to indicate that you want to create the table at household level and you put uplev=person on the age axis to indicate that it is at the person level:
tab age region;anlev=hhold
ttlBase=Households
l age;anlev=hhold;uplev=person
val c(223,224);Base;i;Under 18=0-17;18-25;26-35;
+36-45;46-55;56-65;66+
l region;anlev=hhold
col 126;Base;North;South;East;West
The intermediate file might look like this:
               
         
Region    
        
        
Age        
Household 1   
– North  
1000
Person
1 – 59
0000010
 
 
 
Person
2 – 53
0000110
 
 
 
Person
3 – 26
0010110
Household 2
– East
0010
Person
1 – 36
0001000
As you can see, the cells for age are merged using an ‘or’ comparison to build up an overview of the household before the cells in the final table are incremented.
Note uplev= is only valid on l statements.
By default, the base in an axis updated using uplev= is only incremented for records which contain data at that level. In the example above, the base is incremented for every record read because every person in the household has an age. Suppose, instead, that you have an axis which counts the number of households owning different makes of car. The base for this axis only reports households that own cars — those that do not own a car are excluded.
If you want the base to be incremented for every record containing data at the higher level, regardless of whether it contains data at the lower level, place the option:
levbase
on the base element.
For example:
tab carmake region;anlev=hhold
l carmake;anlev=hhold;uplev=car
n10Base;levbase
col 132;Audi;BMW;Ford;Porsche;Vauxhall;Volkswagen
In this example, the table is created at household level and the carmake axis is at car level. Normally the carmake axis includes only households owning at least one car, but putting levbase on the base element forces Quantum to update the base for every household it reads even if they do not contribute to other elements in the table. This creates a base that is all households, rather than just all households owning cars.
See also
Analysis levels