BookmarkSubscribeRSS Feed
Tpham
Quartz | Level 8

   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

http://i.imgur.com/pT5bDgr.png

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?

6 REPLIES 6
Jay54
Meteorite | Level 14

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;

SGPanel_Split.png

Tpham
Quartz | Level 8

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.

Jay54
Meteorite | Level 14

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.

sasuser_md
Calcite | Level 5

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?

DanH_sas
SAS Super FREQ

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?

sasuser_md
Calcite | Level 5

Yes, the labels for each panel are relatively long, but would fit if split.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 6 replies
  • 4428 views
  • 0 likes
  • 4 in conversation