BookmarkSubscribeRSS Feed
rexc16
Calcite | Level 5

I am trying to sort my proc tabulate by the ALL value. I have searched high and low for a solution and am starting to believe it is not possible!

 

proc tabulate data = trigs MISSING ORDER=INTERNAL out=triggers;

class FileDt;

class LOB;

class TRIG;

var counts;

table (LOB='') * (TRIG=''), (FileDT='' ALL) * (Counts='' *SUM=''*F=Comma12.)/row=float box='by Trigger';

keyLabel ALL = 'Total';

run;

 

I am trying to sort by the value created here - (FileDT='' ALL)

3 REPLIES 3
ballardw
Super User

It may help to provide some output that your are currently getting and the result you want.

 

"ALL" is not sortable as it is a positional category, after all values of FileDt in this case.

If you want the total line to appear first then use (All FileDt).

 

If you want to sort by the value of COUNT statistics that is whole other kettle of fish.

rexc16
Calcite | Level 5

I want to be able to sort by the hightlighted column in the attachment.

 

 


Capture.PNG
ballardw
Super User

The VALUE in your highlighted column is a statistic: The SUM of the variable count. Proc Tabulate doesn't support sorting by statistics directly. One approach might be to create an output data set from tabulate using the out= option, sort the result and use the order=data option but you'll have new variables to play with.

 

If the data you are attempting to display come from summarizing another data set you might be better off going back to the previous dataset and doing something like:

proc tabulate data = trigs MISSING out=triggers;
   class FileDt;
   class LOB;
   class TRIG /order=freq;
   var counts;
   table (LOB='') * (TRIG='' all), 
         (FileDT='' ALL)*n*f=comma6/row=float box='by Trigger';
   keyLabel ALL = 'Total';
run;

Or possibly order=freq descending if you want high to low.

 

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 4063 views
  • 0 likes
  • 2 in conversation