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.
Thanks!
In this code, the resulting tabulate should rank C then A then B.
data one;
input seg $ bal;
datalines;
a 1
a 2
a 3
b 1
b 1
c 15
;
run;
proc tabulate data = one;
class seg /order=freq;
var bal;
tables seg ,
bal = "Balance" *sum='' *f=comma24.0
;
run;
Hi:
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.
cynthia
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.