Data visualization with SAS programming

hbar: legend without subgroup

Accepted Solution Solved
Reply
Regular Contributor
Regular Contributor
Posts: 156
Accepted Solution

hbar: legend without subgroup

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


Accepted Solutions
Solution
‎12-12-2012 08:55 AM
SAS Employee
Posts: 967

Re: hbar: legend without subgroup

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


All Replies
Solution
‎12-12-2012 08:55 AM
SAS Employee
Posts: 967

Re: hbar: legend without subgroup

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).

Regular Contributor
Regular Contributor
Posts: 156

Re: hbar: legend without subgroup

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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