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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 3 replies
  • 1608 views
  • 0 likes
  • 4 in conversation