SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
ZZB
Obsidian | Level 7 ZZB
Obsidian | Level 7

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!

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

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
MikeZdeb
Rhodochrosite | Level 12

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;

ballardw
Super User

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.

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1903 views
  • 0 likes
  • 4 in conversation