Reorder Class Variables

Overview

The ORDER=, ASCENDING, and DESCENDING options enable you to specify the order in which specific class variable categories are listed in your table.
To see how the ORDER= option works in general, look at the following example program. Here the option is applied in the PROC TABULATE statement, so it affects every class variable in the table. In this case, the ORDER=FREQ option has been chosen so that the values will be listed in descending order of their frequency in the data set.
PROC TABULATE DATA=TEMP ORDER=FREQ;
   CLASS GENDER AGE ANS;
   TABLE AGE*ANS=' ',
         (GENDER=' ' ALL)*N=' '*F=10.
         / BOX='Reason for Choice';
RUN;
In Output 9.20, notice how the categories of the variable ANS are listed in order of their frequency. ...

Get PROC TABULATE by Example, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.