BookmarkSubscribeRSS Feed
Obsidian | Level 7

Greetings from Australia.

I produced the following grouped bar chart using SGPLOT.

Not convinced its the best way to present such data but I just do as I'm told 🙂


It needs some stylising which I can easily do.

However, where I work has very strict style requirements.  One being that if the bars in the chart have no outline, then the "bars" in the legend must also have no outline.  (and for coloured bars, no outline is the requirement).

The SGPLOT code I used was

sgplot data=fig_ageSpeo_rates /*noautolegend*/;

vbar age_group/response=value group=qty_sex groupdisplay=cluster barwidth=1 nooutline;

yaxis min=0 max=5000 offsetmax=0 label='Rate';

xaxis label='Age';

keylegend/noborder position=top across=4 location=outside;


Does anyone know an easy way to get the legend 'squares' to not have an outline? (like you would get with SAS\Graph).

I did something with GTL and LEGENDITEMS but that seems way too complicated for most of our users here to have to grapple with.

All advice appreciated.  Am using SAS9.3 on a windows server.  I do also have access to SAS 9.4.


You can work around this behavior by making the outline color to be the same as the background instead of using NOOUTLINE. Try specifying OUTLINEATTRS=(color=white) and see if you get what you want.

Hope it helps!


Obsidian | Level 7

Thanks Dan.

That works nicely on 9.4.  outlineattrs seems to only be in 9.4 though?  Some of users are still on 9.3 (a long story).

I'm guessing there's no 9.3 workaround?


Meteorite | Level 14

There are two ways. 

1.  Derive a new style from the one you like and set the GraphOutlines contrastcolor to the same as the GraphWalls color.

2.  From SGPLOT, write out the GTL code using TMPLOUT=''.  In the GTL code, in the BARCHARTPARM statement, set the OutlineAttrs=(color=GraphWalls:contrastcolor), just like you did in SG.

Obsidian | Level 7

Thanks for the prompt reply late in your day Sanjay. Much appreciated.

I tried option1 but it didn't seem to do anything.  Could you specify the exact syntax for me please?

Option2 works but then with the white outline it now looks like there is a space between the grouped bars, which is not what we want.

Using the outlineattrs option Dan mentioned (in 9.4), did not introduce the 'space' issue though.

Meteorite | Level 14

In GTL, set the option DISPLAY=(FILL) for the bar chart.

Meteorite | Level 14

We dug deeper to review what was happening.  Here is the scoop:

With SAS 9.4, the legend color swatch outlines use the OutlineAttrs.  SGPLOT also supports OutlineAttrs option, so you can use the following code to get the results you want.  Swatches can be made bigger by setting AutoItemSize AND increasing the legend value font size. No change to a style is needed.

proc sgplot;

  vbar origin / group=type response=mpg_city stat=mean groupdisplay=cluster outlineattrs=(thickness=0 color=white);

  keylegend / autoitemsize valueattrs=(size=12);



We discovered that at SAS 9.3, swatch outlines are determined internally.  A work around is possible for a special case that has only bar charts in the graph.    

Obsidian | Level 7

Thanks (again) for following up Sanjay.

Is the workaround for 9.3 the one you have already mentioned (in no.3 of this discussion) or something else?

If its the workaround in no.3   are you able to provide the exact syntact for point 1 of that post?


Obsidian | Level 7

I tried (in SAS9.3) outlineattrs=(color=white thickness=0) in GTL but it still drew a white "outline" and hence there was a small gap between bars (and the legend squares looked a bit small).  I verified this by changing the color to red. The outline appeared.  It seems that (in 9.3) for the outlineattrs in GTL thickness of 0 is in fact the same as 1. 

Meteorite | Level 14

The work around needed to overcome the built in logic is more complicated and will only work if you have a graph that has only a Bar Chart, without combining with other plot types.  It is kind of ugly, so I hesitate to even go there unless this is necessary, and it fits the above restriction.  Is removing the legend swatch outline really important?



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 3 in conversation