07-06-2011 03:25 PM
Any way this can be done? Say I have a data set with segments and balances, I want to order the table by the sum of the balances. I.e. the highest balance segment would be listed first. Order=freq only would work if the balances are proportionate to the units.
07-06-2011 03:40 PM
In this code, the resulting tabulate should rank C then A then B.
input seg $ bal;
proc tabulate data = one;
class seg /order=freq;
tables seg ,
bal = "Balance" *sum='' *f=comma24.0
07-06-2011 08:55 PM
What you want to do is easier to do with PROC REPORT than with PROC TABULATE. Neither REPORT nor TABULATE will order on a calculated statistic (such as your total for BAL), but you can "pre-summarize" the data and create a variable to be used as a "ordering" variable. PROC REPORT output, as shown in the attached screen shot will order on the data (which was ordered by descending ORDBAL in the SQL step. Then, after you understand how PROC REPORT is using the ORDBAL variable, it will also allow you to use the NOPRINT option to hide this ordering variable -- in my program, I have put a comment around the NOPRINT option.