BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data have;

infile datalines;

input setup_date date9. Type $ cnt;

return;

datalines;

 

1jun2019 Central 5

1jun2019 West 6

12jul2019 East 6

14aug2019 West 2

15aug2019 West 1

20aug2019 East 1

;run;

data have2;

set have;

monthsum = month(setup_date);/*returns numeric*/

Month1 = put(setup_date,monyy5.);/*change to character*/

format setup_date date9.;

 

run;

proc report data=have2 wrap style(column)={just=center};

column Type monthsum /*MONTH1*/ setup_date cnt ;

define Type / group style (column)=[cellwidth=100pt] "EXC TYPE";

define monthsum /group noprint order = internal;

 

/*define MONTH1 /across style(column)=[cellwidth=100pt] "MONTH";*/

define setup_date / across order = internal format = monyy5. "Month";

define cnt / sum "Row Total" style(column)=[cellwidth=90pt];

rbreak after / summarize style (summary)= Header;

compute after;

Type = 'Grand Total';

endcomp;

run;

 

The code works without issue however is there a way to sort descending in proc report by the cnt?  Currently I am defining cnt with a sum.  Can it be re-defined in descending order?

 

1 REPLY 1
unison
Lapis Lazuli | Level 10

You can sort beforehand:

proc sort data=have2; by type descending cnt; run;

and then use order=data

define cnt / sum "Row Total" style(column)=[cellwidth=90pt] order=data;
-unison

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 917 views
  • 0 likes
  • 2 in conversation