I'm having some troubles with the x-axis when using proc gplot.
The X-axis should display the values:
31OCT2014 30NOV2014 31DEC2014 ...
but this is not the case. Instead the values are shifted one single day, which means
that the values shown on the x-axis in the plot are:
01NOV2014 01DEC2014 01JAN2015
Does anyone know why this happens? Here's and example:
data test;
input month value;
datalines;
20027 89
20057 139
20088 213
20119 131
20147 371
20178 418
20208 790
20239 532
run;
proc gplot data = test;
plot value * month ;
format month date9. ;
run;
quit;
An additional annoying this is that not only has the x-values shifted one single day, an additional tick mark (01OCT2014) appears in which no corresponding y-value exists.
It hasn't moved your data. It is setting the tick values up in what it can logically assign as a logical order. So your first data item, 31oct, is between 01oct and 01nov. As the logical sequence chosen is 01 of each month, it need to include both of those to be able to plot 32oct which is just off to the left of 01nov. To get round this you need to tell the system what your axis ticks should be, don't let the system guess for you. I don't use the old gplot software, so can't remember the syntax, but if you move to sgplot or graph template it is along the lines of:
xaxis / values=("31oct2014"d "30nov2014"d etc.);
It hasn't moved your data. It is setting the tick values up in what it can logically assign as a logical order. So your first data item, 31oct, is between 01oct and 01nov. As the logical sequence chosen is 01 of each month, it need to include both of those to be able to plot 32oct which is just off to the left of 01nov. To get round this you need to tell the system what your axis ticks should be, don't let the system guess for you. I don't use the old gplot software, so can't remember the syntax, but if you move to sgplot or graph template it is along the lines of:
xaxis / values=("31oct2014"d "30nov2014"d etc.);
Thank you - all of you for a great and quick response.
Your help was strongly appreciated!
proc sgplot data = test;
scatter y= value x= month ;
format month date9. ;
xaxis values=("31oct2014"d "30nov2014"d "01Jan2015"d "28FEB2015"d "31MAR2015"d "30APR2015"d "31MAY2015"d );
run;
quit;
Here's an example, it's close but not exact, but you can play around with the axis statement.
GPLOT, unless told otherwise with an AXIS statement, will default to guessing the "best" display for values. If the variable has a DATE related format then it will make guesses based on dates. If your data had spanned enough years you might only see ticks for January or January and July.
Another way would be to try using a different format such as MONYY7. The ticks will still actually appear on the graph at the first of the month the the "annoying" day of month won't display.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.