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.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 1475 views
  • 3 likes
  • 3 in conversation