BookmarkSubscribeRSS Feed
Shad
Obsidian | Level 7

Hello, 

 

I'm attempting to create a graph to demonstrate variation in medication use by hospitals and region. I think I've gotten close to what I'm after, but I'm running into some struggles while trying to fine tune the figure. 

 

proc sgpanel data=hospitalgraph;
	panelby region / novarname onepanel noborder layout=columnlattice  uniscale=column ;

	vbar ID / response=all_opioid_Mean stat=mean categoryorder=RESPASC barwidth= 0.6 groupdisplay=cluster ;  
	vbar ID / response=methadone_mean stat=mean barwidth= 0.4 groupdisplay=cluster ; 

	rowaxis label="Proportion" discreteorder=data  ;
	colaxis  valueattrs=(size=7) VALUESROTATE=VERTICAL label ='Hospital Number'; 

	format region REGION_.; 
run;

fig.png

 

Specifically, what are some tips/tricks for: 

  • Making the width/space between bars the same for each of the 4 panels?
  • How to force the bar width to be the same each panel, right now it seems to be auto scaling based on the available space
  • I was also struggling with indicating the hospital number horizontally, my work around was to request vertical x-axis IDs however for the hospitals in the Northeast region they're still horizontal, is there a better way to instead of the valuesrotate option?

Thank you, 

SO

5 REPLIES 5
Ksharp
Super User
Try "PROPORTIONAL" option:
panelby year/layout=columnlattice onepanel spacing=0 noborder
colheaderpos=bottom novarname uniscale=row PROPORTIONAL ;
DanH_sas
SAS Super FREQ

In addition to adding the PROPORTIONAL option mentioned by @Ksharp , add FITPOLICY=ROTATEALWAYS to the COLAXIS. This forces the axis tick values to rotate, even if there is no collision.

Shad
Obsidian | Level 7
Thanks @DanH_sas, interestingly when I added the PROPORTIONAL option it forced the axis tick values to be 90 degrees, but I will keep this little tidbit in my back pocket if/when I need it.
DanH_sas
SAS Super FREQ

When you used the PROPORTIONAL option, the spacing for the second cell must have compressed in a way that there were collisions on that axis as well, causing the ROTATE fit policy to be applied there as well.

Shad
Obsidian | Level 7
Thanks @Ksharp. Appreciate the help, that did the trick perfectly.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 5 replies
  • 1218 views
  • 2 likes
  • 3 in conversation