BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Errant
Obsidian | Level 7

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.year.PNG

 

How do I get it to show a tick for every year?

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

View solution in original post

3 REPLIES 3
DanH_sas
SAS Super FREQ

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

Errant
Obsidian | Level 7

It worked great, thank you!

ballardw
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3564 views
  • 1 like
  • 3 in conversation