I'm trying to plot highlow chart using sgplot with the code below. How to make SAS show all years on the x-axis? Currently it shows only even numbers. I've tried different xaxis options but without success.
data have; input year min max; datalines; 2015 10 20 2016 15 25 2017 20 30 2018 25 50 2019 40 45 2020 20 50 2021 10 80 ; run; proc sgplot data=have noborder; highlow x=year low=min high=max / type=bar; run;
Many thanks @ballardw In the meantime, I've discovered that converting years to characters also works. Just in case someone needed
I find the flexibility of the Values = (x to y by z) to be much more flexible than character. Also if your graph size and number of X axis values is "large" then you can have much more control easily than with character values.
You want to use extreme caution with character values for date related issues, especially for those still unenlightened enough to use 2-digit years for any purpose. Display order can be other than expected (99 is way after 01 with 2 digits). Four digit years are generally not a problem but as soon as you move this to DATES you can have issues with too many values and hard to read graphs and/or sort order.
And if character values are used then some plots like Reg don't really work as that requires an actual calculated interval.
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.