Search code examples
sasannotatesgplot

sas sgplot legend & axis labelling


Suppose I have sgplot and my output looks something likeenter image description here

My aim is to adjust the legend and make the bottom section to look something like below. How can I do this? enter image description here


Solution

  • In 9.4 you can use XAXISTABLE to get to what you want. I found that it was easiest to do all of the labelling with XAXISTABLE and abandon the entire XAXIS label.

    proc sgplot data=sashelp.class noautolegend;
      vbox height/category=age group=sex grouporder=ascending;
      xaxis label='' display=NONE;
      xaxistable sex/location=outside label=' ' colorgroup=sex class=sex classdisplay=cluster classorder=ascending;
      xaxistable age/location=outside label=' ' stat=mean;    
    run;
    

    In a previous version it's possible using either annotation or a scatterplot, though the latter won't be perfectly identical to what you want.