Calcite | Level 5

## 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!

1 ACCEPTED SOLUTION

Accepted Solutions
SAS Super FREQ

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

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

3 REPLIES 3
SAS Super FREQ

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

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

Calcite | Level 5

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

Great.  Thank you!

Barite | Level 11

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

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.

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