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
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).
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).
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.