Dear community,
I am trying to sort the sashelp.cars dataset by the values in the individuals type groups:
proc report data=sashelp.cars;
columns make type, horsepower;
define make /group;
define type /across;
define horsepower /max;
So the final output should sort by Wagon BHP, then by Truck BHP, etc. Is this possible without having to transpose and pre-sort the dataset? Thank you for your help in advance!
If you can't do it with order= option such as
define type /across order=data;
Then it's far less trouble to just pre-sort the data in the way you want the across columns to appear.
Hi @js5
I would add 'descending' to the DEFINE statement:
define type /across descending;
In fact, order = data sorts the categories in the order that the variable values are encountered in the data set.
The default order, which is 'formatted' sort the data by the variable’s formatted values.
in your case, I understand that you want an alphabetical descending order.
Best,
Thank you both for your responses! Unfortunately, all the options do is change the order of the type columns. What I need is to sort the make by the max BHP values in the specific colums:
etc. Is this possible with proc report alone, or would I need to transpose the data first?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.