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?
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.
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:
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)
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
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.
data a(keep=y date)
cntl(keep=fmtname start label hlo);
do date='01jan02'd to '08feb05'd;
retain fmtname 'axdate';
if month(date)=1 and day(date)=1 then label=put(date,date9.);
else label=' ';
hlo='o'; label=' '; output cntl;
proc format cntlin = cntl;
axis1 order='01jan02'd to '08feb05'd;
proc gplot data=a;
format date axdate.;
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.