BookmarkSubscribeRSS Feed
BigD
Calcite | Level 5
Hi,

I have a strange behavior in proc report when using formatted across columns.

When I run proc report without the missing statement (as below), I get the correct output in that my hospitals are listed in the proper order, and then the group 'Other' catches the remaining hospitals (see below). When I use the missing statement, the 'Other' group comes first, and I would like it to come last in the list.

proc format ;
value $across_inpatient (notsorted)
'1'='H1'
'2'='H2'
'3'='H3'
'4'='H4'
Other = 'Other';
;run;

ods html;
proc report data= inpatient_join3 nowd ;

column closest_hospital tx_hospital real_separations , sum ;

define tx_hospital/ group across "Treatment Site" order=internal Center format= $across_inpatient. ;
define closest_hospital/ group order=internal format=bri_inpatient. "Closest Hospital" left;
define real_separations/ analysis sum format=comma12.0 '' center;
define sum / "Total" center format=comma12.0 center;

rbreak after / summarize ;
run;
ods html close;

Without Missing:
Closest Hospital H1 H2 H3 H4 Other

With Missing :
Closest Hospital Other H1 H2 H3 H4

How can this be fixed.

Thanks,
2 REPLIES 2
Tim_SAS
Barite | Level 11
Try ORDER=FORMATTED on the DEFINE TX_HOSPITAL statement. Edited by Tim@SAS


Message was edited by: Tim@SAS
BigD
Calcite | Level 5
The order =formatted changes the order to alphabetical order, also not desired.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 2 replies
  • 1078 views
  • 0 likes
  • 2 in conversation