Tables and axes > Introduction to axes > Axes within axes > Defining subaxes
 
Defining subaxes
Quick reference
To mark the start of a subaxis, type:
groupbeg group_name [, group_name2, ... ]
To mark the end of a subaxis, type:
groupend group_name [, group_name2, ...]
If the elements forming a subaxis are scattered throughout the axis, flag each one with the option:
group=group_name [, group_name2, ...]
More information
There are two ways of allocating elements to a subaxis, depending on whether or not the elements come one after the other in the main axis. If the elements forming a subaxis do come one after the other, they can be grouped by placing the statement:
groupbeg groupname
on the line immediately above the first element, and:
groupend groupname
on the line immediately after the last element in the group.
For example:
l allchoc
n10Base
n01Trouble undoing wrapping;c=c142'8'
n01Didn't like plastic wrapping;c=c141'1'
groupbeg taste
n01Too sweet;c=c141'4'
n01Chocolate coating was too sweet;c=c141'7'
n01Chocolate coating was awful;c=c141'0'
n01Not sweet enough;c=c141'5'
n01No taste at all;c=c141'3'
groupend taste
n01DK/NA;c=c(141,142)=$ $
Here is a subaxis containing comments about the taste of a chocolate bar. It can be used as an axis in its own right by naming it on a tab statement, or its elements can be treated as part of the main axis when that axis is used in a table. In the latter case, the groupbeg/end statements will be ignored.
If an element forms the start (or end) of more than one group, the group names can be listed on the same statement, separated by commas, thus:
groupbeg taste,coating
n01Chocolate coating was too sweet;c=c141'7'
n01Chocolate coating was awful;c=c141'0'
You can enter the same group name for several blocks of elements in the main axis. This provides for occasions when a subaxis comprises more than one set of consecutive elements. For example, you might want to create a subaxis of comments about the chocolate bar itself, but exclude comments about the wrapping or the price:
l allchoc
n10Base
n01Trouble undoing wrapping;c=c142'8'
n01Didn't like plastic wrapping;c=c141'1'
groupbeg bar
n01Too sweet;c=c141'4'
n01Not sweet enough;c=c141'5'
n01No taste at all;c=c141'3'
groupend bar
n01Too expensive;c=c142'1'
n01Not what I would buy;c=c142'2'
groupbeg bar
n01Chocolate coating was too sweet;c=c141'7'
n01Chocolate coating was awful;c=c141'0'
groupend bar
n01DK/NA;c=c(141,142)=$ $
An axis can contain up to 32 subgroups of this type, and the groups can overlap (that is a second subaxis can be started before the first one is finished) or they can be nested (that is a subaxis can contain another subaxis). The example below shows a nested subaxis for comments specifically about the taste of the chocolate coating:
groupbeg taste
n01Too sweet;c=c141'4'
groupbeg ctaste
n01Chocolate coating was too sweet;c=c141'7'
n01Chocolate coating was awful;c=c141'0'
groupend ctaste
n01Not sweet enough;c=c141'5'
n01No taste at all;c=c141'3'
groupend taste
Here is another example with overlapping subgroups:
l allchoc
n10Base
n01Trouble undoing wrapping;c=c142'8'
n01Didn't like plastic wrapping;c=c141'1'
groupbeg bar,sweet
n01Too sweet;c=c141'4'
n01Not sweet enough;c=c141'5'
groupend sweet
n01No taste at all;c=c141'3'
groupend bar
n01Too expensive;c=c142'1'
n01Not what I would buy;c=c142'2'
groupbeg bar,sweet
n01Chocolate coating was too sweet;c=c141'7'
groupend sweet
n01Chocolate coating was awful;c=c141'0'
groupend bar
n01DK/NA;c=c(141,142)=$ $
When the elements in a group are scattered throughout the axis (as in the previous example), or when an element belongs to all subaxes in the main axis, the element can be flagged with the option:
group=groupnames
on the element itself, where groupnames is a comma-separated list of the groups in which the element belongs.
For example:
l allchoc
n10Base;group=all
    .
n01Too sweet;c=c141'4';group=sweet
n01Chocolate coating was too sweet;c=c141'7';group=sweet,coating
n01Chocolate coating was awful;c=c141'0';group=coating
n01Not sweet enough;c=c141'5';group=sweet
n01No taste at all;c=c141'3'
The special group name ‘all’ is used for elements which belong in all subaxes. In the example, the Base element is to be included in all groups.
An axis can contain both types of grouping, and an element can be present in more than one group. Elements which are not part of a groupbeg/end group and which do not have the group= keyword are part of the main axis only: it is not an error for an element to be omitted from all subaxes.
Note Quantum does not allow a subaxis to be created from the elements of more than one axis. To do this, it is necessary to create a completely new axis and to copy the required elements into it.
See also
Axes within axes