DATA Step, Macro, Functions and more

Date axis in proc gplot

Reply
Contributor ZZB
Contributor
Posts: 40

Date axis in proc gplot

Hello,

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

Thanks!

Trusted Advisor
Posts: 1,137

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

Thanks,

Jag

Thanks,
Jag
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.;

datalines;

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

run;

quit;

Super User
Posts: 11,343

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
  • 331 views
  • 0 likes
  • 4 in conversation