Sorts tables so their margins are in ascending or descending order (R.W. Payne).
|Controls output (
||Direction of sorting (
||Method to use to construct a marginal table for the sorting of a factor when there is no one-way table classified by the factor in the
||Specifies or saves a list of classifying factors of the tables in the
||Specifies or saves a list of classifying factors of the new tables, corresponding to those in the
||Factors to exclude from sorting|
||Number of (best) levels to include from each sorted factor; default
||Tables to be sorted|
||Allows the new sorted tables to be saved|
||Title to be used when displaying each table|
||Field width for printing each table|
||Decimal places for each table|
This procedure sorts tables so that their margins are in a specified order. With a multi-way table, for example, this may help in interpreting an interaction from an analysis of variance. With a one-way table, it allows the cells to be displayed in ascending order, as in a Pareto chart.
The original tables are supplied by the
TABLE parameter. The
NEWTABLE parameter can be used to save the sorted tables.
If you want to specify your own ordering, the
NEWFACTORS options can be set to pointers of pre-defined factors indicating the ways in which each dimension of the tables is to be sorted:
FACTORS contains factors from the classifying sets of the original tables, and
NEWFACTORS contains the corresponding factors for the new tables (with the levels in the new order).
Alternatively, you can let
TABSORT define the ordering. For each factor classifying the original tables, the ordering is obtained using a one-way table for that factor. This may be available amongst the list of original tables (specified by the
TABLE parameter). If not,
TABSORT finds the first table in the list with the factor in its classifying set. If the table has margins, then
TABSORT will extract the appropriate one-way margin. Otherwise, it first constructs the margins using the
MARGIN directive; the
METHOD option then defines how the margin is formed (using means, medians and so on). Having obtained a suitable one-way table,
TABSORT forms a new factor whose levels are in the order that will arrange the entries of the table in either ascending or descending order according to the setting of the
DIRECTION option (default
NEWFACTORS options can then be used to save pointers containing the factors and reordered factors for future use. Note also, that even if you do not want to use the factors in future, you can use the pointers to specify identifiers for the new factors to be used when the tables are printed. (You must specify both of them, so that
TABSORT can tell how the new identifiers correspond to the original factors.) The
EXCLUDE option can be set to a pointer containing factors that are not to be re-ordered automatically, but should be left unchanged.
NBEST option specifies the number of levels to include from each sorted factor. So, setting
NBEST=5 would take only the first five levels in the sorted order. This may be useful if you have a large table, and want to show only the best part of the table (as defined by the sorting of the margins). This default is to include all of the levels.
TABSORT. The setting
tables prints the tables. The setting
histograms, causes any one-way tables to be plotted by the
DHISTOGRAM directive, and any two-way tables to be plotted by
TITLE parameter allows you to supply a title to be used in the display of each table. The
FIELDWIDTH parameter specifies field widths, and the
DECIMALS parameter specified numbers of decimal places.
CAPTION 'TABSORT example',\ 'Data from Snedecor & Cochran (1980), Statistical Methods',\ '(seventh edition), p.305.'; STYLE=meta,plain FACTOR [NVALUES=60; LABELS=!T(Beef,Cereal,Pork); VALUES=(1...3)20] Source FACTOR [NVALUES=60; LABELS=!T(High,Low); VALUES=3(1,2)10] Amount VARIATE [NVALUES=60] Gain READ Gain 73 98 94 90 107 49 102 74 79 76 95 82 118 56 96 90 97 73 104 111 98 64 80 86 81 95 102 86 98 81 107 88 102 51 74 97 100 82 108 72 74 106 87 77 91 90 67 70 117 86 120 95 89 61 111 92 105 78 58 82 : TREATMENTS Source*Amount ANOVA [PRINT=means; FPROBABILITY=yes] Gain AKEEP Source*Amount; MEANS=SourceMeans,AmountMeans,SourceByAmountMeans TABSORT [PRINT=tables] SourceMeans,AmountMeans,SourceByAmountMeans