DATA Step, Macro, Functions and more

Date axis in proc gplot

Contributor ZZB
Posts: 43

Date axis in proc gplot


I have a problem in date axis in proc gplot.  If I do nothing, the time axis is '1985/01 ... 1990/01.....1995/01....2000/01....2005/01.....2010/01.....2015/01'.

The ideal time axis I want to get is '1988/08 .......1992/12 or 1992/08...............2014/12' OR '1988 ....only year .......  2014'

What should I add in the option 'axis'? I try to use 'order()' in the axis, but it does not work well. How to make the time axis look better?

The data is as follow:

date                    Cum_Ret

1988/08                 xxx

1988/09                 xxx

....                           ...


2014/12              xxxx


Trusted Advisor
Posts: 1,147

Re: Date axis in proc gplot

please try to read the date using the yymmn6. informat in the datastep. this will convert the date to numeric values. then sort the data on this numeric value and when you use the date in proc gplot apply the format yymms10. This will display the date as expected.

when you try to use the informat, try the below statement date2=input(compress(date,'/'),yymmn6.);



Valued Guide
Posts: 765

Re: Date axis in proc gplot

Hi.  Give this a try ...

data x;

input date :anydtdte. cum_ret;

format dt yymon.;


1988/08  100

1988/09  200

1995/11  300

2005/07  220

2014/12  150


goptions reset=all gunits=pct;

axis1 order=0 to 350 by 50 label=(a=90);

axis2 minor=none;

symbol1 f='wingdings' v='6c'x h=2;

proc gplot data=x;

plot cum_ret*date / noframe vaxis=axis1 haxis=axis2;

format date year.;



Super User
Posts: 13,564

Re: Date axis in proc gplot

I would say that two endpoints don't really describe a desired axis very well. Do you want annual, month, quarterly or some other interval to appear on the axis? And is your date variable a SAS date or not?

Some of the issue is that your are apparently trying to display 26 years of data.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation