Advanced tables and statistics > Other tabulation facilities > Sorting tables > Totals, statistics and manipulated elements in sorted tables
 
Totals, statistics and manipulated elements in sorted tables
Subtotals, totals, statistical elements and elements created using m statements are not sorted unless you place the sort keyword on the element itself.
Sorting takes place after the cell counts for these elements have been calculated, not before, and subtotals and totals are not recalculated after elements have been sorted. If you are careless in the way you write your spec you could create tables that look wrong because the order of elements in the axis has changed after the cells’ values were calculated.
See
Sorted tables of means
See also
Sorting tables