Hi everyone,
I'm trying to create a graph, that delineates everything by year.
proc sgplot data=HW2.earthquakes(where=(year >= 2000)); XAXIS interval = year; Scatter X = year Y = magnitude; Title 'Magnitude of Earthquakes occuring in 2000 and beyond'; run;
When I run this code, I wind up with up with a graph that still shows ticks in two year increments.
How do I get it to show a tick for every year?
Judging by the plot, YEAR is not really a datetime variable, so INTERVAL will not work for you. For this case, I think you just want to set TYPE=DISCRETE on the XAXIS statement instead of using the default linear axis for numeric data.
Hope this helps!
Dan
Judging by the plot, YEAR is not really a datetime variable, so INTERVAL will not work for you. For this case, I think you just want to set TYPE=DISCRETE on the XAXIS statement instead of using the default linear axis for numeric data.
Hope this helps!
Dan
It worked great, thank you!
To force display of tick mark values add a VALUES option to the XAXIS statement such as VALUES=(2000 to 2011 by 1) instead of INTERVAL.
It may be that just removing INTERVAL= would work but depending on the range of values and the display size each year may not receive a tick mark.
The interval option is going to want a DATE, TIME or DATETIME valued variable for the x value and yours is very likely not from the display and values shown.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.