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.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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