Advanced tables and statistics > Other tabulation facilities > Sorting tables > Text-only elements in sorted tables
 
Text-only elements in sorted tables
Text-only elements created with n03 statements automatically attach themselves to the next numeric element in the axis and are sorted with that element. If there is no subsequent numeric element, or the sort level changes (for example, with a new net statement or with subsort) the n03 remains unsorted. To force an n03 to be unsorted, add the option nosort at the end of the statement.
n33 statements which define continuation text attach themselves to the element whose text they continue and remain with that element if it is sorted.
Subheadings created with n23 statements are always unsorted unless they specifically carry the option sort.
The two examples below show how to use an n03 to separate unsorted No Answer and Don’t Know responses from the rest of the table. The overall layout that you want to achieve is this:
Efficacy Net
  Comments
  Freshening Sub-Net
    Comments
Fragrance Net
  Comments
  Fragrance Intensity Sub-Net
    Comments
Miscellaneous
  Comments
DK/NA
The highest level is the two nets and the group of miscellaneous statements. The second level is the comments within these groups, and the third level is the comments within the two sub-nets.
Before you write the axis, there are some other points to bear in mind. First, the group of miscellaneous comments and the DK/NA row are to remain in that order at the bottom of the axis, even though the miscellaneous comments themselves are to be sorted. Second, all subnets are to remain at the end of the main net, even though their components are to be sorted. Third, since there will only be a few rows in the efficacy net, they are not to be sorted at all.
Here is the axis:
tab dislike ban1;sort
l dislike;netsort
ttlTable 5: What is there about this product
ttl         that you think you would dislike?
n10Total Respondents
net1EFFICACY (Net)
n33==============
n01Doesn't Work;c=c223'12';nosort
n01Other Efficacy Comments;c=c223'&';nosort
net2 Freshening (Sub-Net)
n33---------------------
n01 Doesn't Freshen Room;c=c223'7';nosort
n01 Other Freshening Comments;c=c223'&';nosort
net1FRAGRANCE (Net)
n33===============
n01Dislike Fragrance;c=c224'125'
n01Smells Artificial;c=c224'3'
n01Fragrance Name not Descriptive Enough;c=c224'4'
n01Other Fragrance Comments;c=c224'&';nosort
net2 Fragrance Intensity (Sub-Net)
n33------------------------------
n01Strong Overpowering Smell;c=c227'1'
n01Weak Fragrance/ Not Strong Enough;c=c227'2'
n01Other Fragrance Intensity Comments;c=c227'34&';nosort;endnet1
ntt1MISCELLANEOUS
n33=============
n01Doesn't Last Long;c=c225'1'
n01Too Expensive;c=c225'7'
n01More Expensive Than Other Products;c=c225'8'
n01Difficult / Inconvenient to Use;c=c228'1/4'
n01Don't Buy This Type of Product;c=c226'12'
n01Might be Harmful / React Chemically;c=c226'34'
n01Allergic to This Type of Product;c=c226'678'
n01Prefer Other Types of Products;c=c226'90–'
n01Other Miscellaneous Comments;c=c226'&'.or.c229'1';nosort
n03
n01Nothing Disliked;c=c232'–';nosort
n01Don't Know / No Answer;c=c232'0&';nosort
l ban1
col 116;base=Total;London;Leeds;Cardiff;Glasgow
Because you want a sorted table, start by putting the keyword sort on the tab statement. This sorts all rows which are not part of a sublevel, namely the two net rows, the miscellaneous row, and the two rows at the end of the axis. The nets are counts of people and are therefore created by net statements, but Miscellaneous is a heading only and is therefore created by an ntt at the appropriate level. The rows entitled ‘Nothing Disliked’ and ‘Don’t Know/No Answer’ are to remain in their original places so they take the option nosort.
When the table is sorted, the two top level nets are sorted according to the number of respondents they contain, and within that the subgroups are sorted. The group of miscellaneous comments is sorted but retains its original place in the axis (after the two nets).
The other way of writing this axis is to use subsort and endsort in place of netsort:
l dislike
ttlTable 5: What is there about this product
ttl         that you think you would dislike?
n10Total Respondents
net1EFFICACY (Net)
n33==============
n01 Doesn't Work;c=c223'12';subsort;nosort
n01 Other Efficacy Comments;c=c223'&';nosort;endsort
net2 Freshening (Sub-Net)
n33--------------------
n01 Doesn't Freshen Room;c=c223'7';subsort;nosort
n01 Other Freshening Comments;c=c223'&';endsort;nosort
net1FRAGRANCE (Net)
n33===============
n01 Dislike Fragrance;c=c224'125';subsort
n01 Smells Artificial;c=c224'3'
n01 Fragrance Name not Descriptive Enough;c=c224'4'
n01 Other Fragrance Comments;c=c224'&';nosort;endsort
net2 Fragrance Intensity (Sub-Net)
n33-----------------------------
n01 Strong Overpowering Smell;c=c227'1';subsort
n01 Weak Fragrance/ Not Strong Enough;c=c227'2'
n01 Other Fragrance Intensity Comments;c=c227'34&';nosort;endsort;endnet1
ntt1MISCELLANEOUS
n33==============
n01 Doesn't Last Long;c=c225'1';subsort
n01 Too Expensive;c=c225'7'
n01 More Expensive Than Other Products;c=c225'8'
n01 Difficult / Inconvenient to Use;c=c228'1/4'
n01 Don't Buy This Type of Product;c=c226'12'
n01 Might be Harmful / React Chemically;c=c226'34'
n01 Allergic to This Type of Product;c=c226'678'
n01 Prefer Other Types of Products;c=c226'90–'
n01 Other Miscellaneous Comments;c=c226'&'.or.c229'1';nosort;endsort
n03
n01Nothing Disliked;c=c232'–';nosort
n01Don't Know/ No Answer;c=c232'0&';nosortcR
Here, the first row in each net has the keyword subsort, indicating that it and all subsequent rows form a subgroup of the net and are to be printed in rank order beneath it. The group of miscellaneous comments also form a subgroup. Subgroups are terminated by the keyword endsort.
Even though the subnets Freshening and Fragrance Intensity are part of the nets, they are dealt with as a separate group within the net and they have their own subsort/endsort group. This is because you want to keep all comments to do with freshening and fragrance intensity under their respective net rows. If you left them as part of the overall Efficacy or Fragrance net, the individual comments would be sorted with the other comments in those nets according to their size, rather than being kept together as a subgroup.
See also
Sorting tables