Why don't the labels for the colors in my stacked chart show at the bottom?
title "100% Stacked Bar Chart";
proc sgplot data = freqout keylegend;
vbar Event_Entered_Month / response=Percent group = buckets groupdisplay=stack;
xaxis discreteorder=data DISPLAY=ALL;
yaxis grid values=(0 to 100 by 10) DISPLAY=ALL label = "Percentage of Total by Month" ;
run;
KEYLEGEND is not an option on the PROC SGPLOT statement -- it is its own statement. For this example, the legend should automatically appear, unless the legend takes up greater than 20% of the graph area (check your log for a note). If it is dropped due to size, you can adjust that size threshold by using the MAXLEGENDAREA option on the ODS GRAPHICS statement. There is a NOAUTOLEGEND option on the PROC statement that disables this automatic legend. The KEYLEGEND statement can be used to create a custom legend or modify attributes of the automatic legend. See the documentation for examples.
Hope this helps!
Dan
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.