So this is my code thus far:
PROC SGPANEL DATA=new&file;
PANELBY nb/rows=&rows columns=&cols spacing=5 novarname;
VBOX value/category=combined;
FORMAT nb &fmt..;;
%IF %UPCASE(&refline)^= %THEN %DO;
refline &refline / axis=y lineattrs=(pattern=5);
%END;
rowaxis values=(&range) label="&label";
colaxis display=(nolabel);
refline 0 / axis=y;
WHERE &wh;
RUN;
This is the bottom of the output
Sadly This is the labels I need to keep for this graph, but I am hoping to make it so it doesn't present it at an angle, but instead multiple lines.. I was told I should split the character label, but I have no idea how to do that. I did find the splitchar statement (SPLITCHAR=“character-list") within the SAS documentation, but I can't find examples on how to apply it. I am unsure if this is the right statement that I should use to make it the way I want it.
Does anyone have any ideas?
The solution depends on the release of SAS you are using. Always include that with your question. Please see
Since you see the SPLITCHAR option in the doc, you are likely using SAS9.4 or later release. You need to set the FITPOLICY=SPLIT on the COLAXIS. Here is sample code and what you get.
ods graphics / reset width=8in height=3in;
proc sgpanel data=sashelp.heart;
panelby weight_Status / columns=3 onepanel ;
vbar deathcause;
colaxis fitpolicy=split;
run;
Thanks for this, I was wondering, is there a way for it to work on 9.2 also? So I am on 9.4 but other coders I am working with are on 9.2.
No, there is no simple option prior to SAS 9.4 that will do this for you.
With SAS 9.3, you can use the SG Annotatio feature to draw split tick values with some extra effort. You will need to turn off the axis tick values, and use the SG Annotation TEXT function to render the values. This function can automatically split the words in a text string in a certain width.
For SAS 9.2, my suggestion would be to switch the Row and Col axis variables so the long text strings will go you the Y axis.
Suppose you wanted to split the PANELBY labels instead? (So, in the example above it would be the "Weight Status = " labels.) Is that possible in V9.4?
Not really. The "label" is really a name/value pair.The best option for shrinking the header in this particular example is to use the NOVARNAME to get rid of the name part (i.e. "weight_status =") and incorporate the "weight status" reference into the title or footnote. Do you have a case where the value part needs to be split?
Yes, the labels for each panel are relatively long, but would fit if split.
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!
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.