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-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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