## Maximum number of ticks/months for PROC SGPLOT

Solved
Occasional Contributor
Posts: 19

# Maximum number of ticks/months for PROC SGPLOT

Hi all,

Is there a way to limit the number of tick marks on the x axis on a PROC SGPLOT series graph?  My data is set up by month and I only want to show 18 months at a time (the most recent 18 months).  Is there a way to set this up so that each month, the oldest month rolls off?  Thanks in advance!

Accepted Solutions
Solution
‎01-20-2015 09:51 AM
SAS Super FREQ
Posts: 975

## Re: Maximum number of ticks/months for PROC SGPLOT

Posted in reply to RobertHuey

The best way to do this is to put a WHERE clause on PROC SGPLOT with a macro variable for the date value. Then, compute the date value relative to the current date and set it on the variable.

As for tick value control, you can use the INTERVAL option on the SGPLOT axis statements to control the time interval displayed for the major tick marks.

Hope this helps!

Dan

All Replies
Solution
‎01-20-2015 09:51 AM
SAS Super FREQ
Posts: 975

## Re: Maximum number of ticks/months for PROC SGPLOT

Posted in reply to RobertHuey

The best way to do this is to put a WHERE clause on PROC SGPLOT with a macro variable for the date value. Then, compute the date value relative to the current date and set it on the variable.

As for tick value control, you can use the INTERVAL option on the SGPLOT axis statements to control the time interval displayed for the major tick marks.

Hope this helps!

Dan

Occasional Contributor
Posts: 19

## Re: Maximum number of ticks/months for PROC SGPLOT

Great.  Thank you!

Super Contributor
Posts: 257

## Re: Maximum number of ticks/months for PROC SGPLOT

Posted in reply to RobertHuey

Hello,

You can use the VALUES option in the XAXIS statement to control the tick marks on the x-axis.

If your x-value is a date value then you can use something like this below:

`XAXIS VALUES = ("25MAY08"d "04JUL08"d "23AUG08"d);`

The above code will places tick marks at 25MAY08, 04JUL08, and 23AUG08. You can edit it to get what you want though, for example put the 18 months of your choice.

You could also use a where clause in your dataset to limit to observations to the last 18 months.  This can be done automatically using the &sysdate and also finding out the date of &sysdate - 18 months.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 3 replies
• 554 views
• 3 likes
• 3 in conversation