i am creating a scatter plot and i want to add the actual values on each bar.
proc sgplot data = consolidated;
vbar channel/group = subchannel groupdisplay = stack;
how do i get the values to show on the bars?
Thank you. that solved it 🙂
how do i show the label on a stack thats really small though?
Depending on the actual data and how important it may be to show something like 0.01% (just an example) there are a few options that may work.
Make the graph physically taller (or wider for HBAR), the ODS GRAPHICS option lets you control the height/width of the graph display area. This probably most useful if the text almost fits.
The SEGLABELATTRS can modify text size of the labels so a smaller or different font may work. Again more likely if the current text almost fits.
For extremely small values it may be better to create a custom format for the variable that would suppress text , show a "blank" value for very small ranges. That at least keeps from getting collisions and hard to read text.
If you "know" that several group values are consistently extremely small individually create a group value that represents 2 or more categories and provide an appropriate group definition. This may make more sense if the "groups" represent some sort of order that naturally places them together.
You can create an annotate data set and use the SGANNO option on the Proc statement to use the set. This is a bit of work as then you have to provide coordinates for where you actually want text to appear as well as the text. Sometimes with VBAR and character axis values this can be a challenge. I would use this in conjunction with the custom format suppressing the small values on the bar and then just display the value off to the side of the bar.
Related to this is using the VBARBASIC, to allow sharing with other types of charts and modify you existing data to include some additional values/variables to do a TEXT plot overlaying the graph with the label values. Again this might be just the "small" values. Both of these overlay approaches often work better with summarized values instead of letting VBAR build the heights using the internal stats.
Sometimes vertical scales might work such as a Log scale for the Yaxis but that only helps if the "small" values to display are actually appearing at the base of the bar.
Unless there is a lot of $$$ involved for the exact values of the small segments I tend to suppress the values on the actual bar and then use a footnote or other explanatory text that indicates the range of values that were suppressed.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.