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

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
DanH_sas
SAS Super FREQ

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

View solution in original post

3 REPLIES 3
DanH_sas
SAS Super FREQ

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

RobertHuey
Calcite | Level 5

Great.  Thank you!

djrisks
Barite | Level 11

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.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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