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

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.);

 

 

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.);

 

 

haw
Calcite | Level 5 haw
Calcite | Level 5

Thank you - all of you for a great and quick response.

 

Your help was strongly appreciated!

Reeza
Super User
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. 

 

 

ballardw
Super User

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.

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!

What is Bayesian Analysis?

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.

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