BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
A_M_
Fluorite | Level 6

Hello,

I am using sgplot to do 2 histograms in a figure, comparing the distribution of 2 groups (one in blue, one in red). I chose to keep the histogram bars empty (nofill option). The legend therefore shows only a colored line, one red and one blue. I would however like to have boxes in the legend, not lines. To match the appearance of my histogram bars, I would like to therefore have empty/white boxes, with colored outlines matching my groups. I can't seem to figure out how to do this. I can either have just lines, or fully colored red and blue boxes. Any experience/ideas with that? Thanks a lot!

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

The way to do that is to set the FILLATTRS color to be the same color as the wall (white, for example) instead of turning the fill off. That way, the legend treats the representation as if it was filled, giving you the box. Let me know if this works for you.

 

Thanks!

Dan

View solution in original post

3 REPLIES 3
DanH_sas
SAS Super FREQ

The way to do that is to set the FILLATTRS color to be the same color as the wall (white, for example) instead of turning the fill off. That way, the legend treats the representation as if it was filled, giving you the box. Let me know if this works for you.

 

Thanks!

Dan

A_M_
Fluorite | Level 6
Works great. Thanks!
DanH_sas
SAS Super FREQ

For the record, there is another way to do this that might even be more desirable. Instead of specifying the COLOR in FILLATTRS to the background color, just set TRANSPARENCY=1 in the FILLATTRS. That way, you will get the correct appearance regardless of the ODS style you use.

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
  • 3 replies
  • 643 views
  • 3 likes
  • 2 in conversation