BookmarkSubscribeRSS Feed
ottoh
Fluorite | Level 6
Hey guys, I was hoping you could help me out.

I am trying to plot some time series data but when I force a start/end/interval, the end data gets cut off at the final tick mark.

For example, I am graphing data from 1/1/02 to 2/4/10 and I want the axis to end at 2/4/10 when the data stops (everything plots fine with no order statement but the axis goes until 2011).

If I make an order statement, unless the by interval exactly ends with the last tick mark on 2/4/10, the chart will cut off everything after the final tickmark. In this example, I could have 5 tickmarks with an interval of 739 days and it would be fine (since the final tick mark is on 2/4/10) but if I tried to use "by year", it would place the last tick mark on 1/1/10 and not graph the remaining month or so of data.

Is there any way to get gplot to go beyond the final tick mark?
Thanks
8 REPLIES 8
GraphGuy
Meteorite | Level 14
I assume you are using 'proc gplot'?

What device are you using? such as device=png.

Could you show us the exact axis statement?
ottoh
Fluorite | Level 6
using device=SASPRTC and ods pdf

an example axis would be:
axis1 order= '01jan02'd to '04feb10'd by year;

The data being has a date and a value for each trading day in the above date range.
Again, this plots fine without an order statement (but the axis doesn't cut off at 2/4/10 like I want it to).
I can make it work if I do:
axis1 order= '01jan02'd to '04feb10'd by 739;
since 739 is a factor of the number of days between the dates but this will only work when there are exact factors (the number of days between 1/1/03 and 2/4/10 is prime so there is no solution) and it gives me zero control over how many tick marks I would like.

Ideally, I would be able to have a tick mark on january 1st of every year (or several tick marks per year) and not have to worry about my data being cut off before the end.
GraphGuy
Meteorite | Level 14
I think that if you're using "by year" in an axis order statement, you will need to make sure that your 'from' and 'to' values are evenly space by year.

In a case like yours, I'm not sure that the software would know what to do ...

order= '01jan02'd to '04feb10'd by year

I think you'll need to use something like ...

order= '01jan2002'd to '01jan2011'd by year
ottoh
Fluorite | Level 6
Even if I don't use by year (say I use 'by 200'), this error crops up.

If I do
order= '01jan2002'd to '01jan2011'd by year
It will pull my date axis all the way out to 1/1/2011 leaving a bunch of blank space which I do not want (this is what happens if I simply use no order statement at all).

an example of what I want would be if you graphed the following data in excel:
1/1/2010 5
1/2/2010 6
1/3/2010 7
1/4/2010 8
1/5/2010 9
1/6/2010 10
and set the axis min to 1/1/2010, axis max to 1/6/2010, and major unit to 3, it would print axis labels for 1/1/2010 and 1/4/2010 but it would still graph the values for 1/5/2010 and 1/6/2010 (SAS just cuts these off)
GraphGuy
Meteorite | Level 14
I guess it's a matter of preference, and I can see advantages and disadvantages to doing it either way.

Personally, I prefer the gplot way - only plot the markers that fall within the axes. Imho, if you plot markers that are outside the axis min/max values, then you could run into data-integrity problems of the end user assuming the markers fall within the axis min/max values, when they actually don't (this is especially problematic when the values are just barely outside the axis min/max).

That being said, I believe that is the way the new 'proc sgplot' handles axes, so you might want to give that a try, if you've got v9.2
ottoh
Fluorite | Level 6
Well, I want the markers that fall within the axes...they just don't fall within the tick marks.

Thanks for the sgplot suggestions. I would prefer to use it but I have to get this to work on 9.1 so I guess I will just stick with finding a factor that fits my time period.
ArtC
Rhodochrosite | Level 12
You could make a user defined format that covers all the days and then only shows the values for selected days. Consider the following GPLOT example.
[pre]
data a(keep=y date)
cntl(keep=fmtname start label hlo);
do date='01jan02'd to '08feb05'd;
y+1;
output a;
retain fmtname 'axdate';
start=date;
if month(date)=1 and day(date)=1 then label=put(date,date9.);
else label=' ';
output cntl;
end;
hlo='o'; label=' '; output cntl;
label=
run;
proc format cntlin = cntl;
run;
axis1 order='01jan02'd to '08feb05'd;
proc gplot data=a;
plot y*date/haxis=axis1;
format date axdate.;
run;
quit;
[/pre]
DanH_sas
SAS Super FREQ
For classic SAS/GRAPH procedures like GPLOT, the data is bounded by the first and last tick marks. The only way I can think of to get around that is to use annotate. However, if you're a using SAS 9.2, the ODS Graphics system does not have this limitation. You could use PROC SGPLOT to display the desired tick marks without affecting your data range. Let me know if you want more details.

Thanks!
Dan

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 8 replies
  • 1990 views
  • 1 like
  • 4 in conversation