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

Dear all,

in the sas help I read that there is no legend displayed in a hbar graph when I don't use subgroup. My customer nonetheless wants one 😞 How can I do it? Here's my code:

patternid1 value=solid color=red;

patternid2 value=solid color=blue;

patternid3 value=solid color=green;

legend1 label=none position=(bottom center outside);

proc gchart data = mydata;

     vbar year / sumvar = mysum

                    group = mygroup

                    type = sum

                    discrete

                    patternid = midpoint

                    legend = legend1;

run;

quit;

The legend here is not displayed.

Best wishes,

Eva

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

If you want a legend, I think you can use subgroup=year, rather than patternid=midpoint.

I'm not a big fan of coloring each bar differently, for the sake of coloring each bar differently though. Make sure your chef realizes that the legend will be redundant with the labels on the maxis (they will both be showing the year).

View solution in original post

2 REPLIES 2
GraphGuy
Meteorite | Level 14

If you want a legend, I think you can use subgroup=year, rather than patternid=midpoint.

I'm not a big fan of coloring each bar differently, for the sake of coloring each bar differently though. Make sure your chef realizes that the legend will be redundant with the labels on the maxis (they will both be showing the year).

Eva
Quartz | Level 8 Eva
Quartz | Level 8

Dear Robert,

it works. Thanx a lot. And I agree what you say about the legend being twice the information I already have on the maxis. Though I told him this the customer wants the legend withoug the values written on the maxis. That's life.

And yes, the colored bars become a problem when they change in number - 5 instead of 3. But we have to use the company's colors instead of SAS standrad colors. It would be great if I could say: use any shade of blue for whatever number of bars.

Best wishes

Eva

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 919 views
  • 0 likes
  • 2 in conversation