Data visualization with SAS programming

How do I split labels in SGPanel?

Posts: 58

How do I split labels in SGPanel?

   So this is my code thus far:


  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);


  rowaxis values=(&range) label="&label";

  colaxis display=(nolabel);

  refline 0 / axis=y;

  WHERE &wh;


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?

Posts: 1,139

Re: How do I split labels in SGPanel?

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;



Posts: 58

Re: How do I split labels in SGPanel?

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.

Posts: 1,139

Re: How do I split labels in SGPanel?

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.

Ask a Question
Discussion stats
  • 3 replies
  • 2 in conversation