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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 772 views
  • 0 likes
  • 2 in conversation