I have to chart 5 years of usage data, one bar for each month. A request has come to show all 5 years worth of bars, but only have quarterly values appear on the horizontal axis. Is there an easy way to do this?
GCHART AXIS statement controls the number of tickmarks and the values displayed. Likely to get this to work you will need DATE values for your x axis. Is that the case?
And due to interaction it might help to show your current GCHART code.
Or consider changing to Proc SGPLOT. If you consider this option we need to know which version of SAS you are running as there have been many changes to options in the past few releases.
Change your aggregations to quarterly. If you're doing aggregations in the GCHART (can't even remember if that's possible) format your date with a quarter format and see if that changes things.
If you're aggregating your data outside of the GCHART proc then change it there.
Also, consider switching to SGPLOT if that's an option. Much better quality graphics.
As Ballardw asked earlier, what is the release of SAS (with maintenance level) are you using. This is important. With SAS 9.40M3, you can make bar charts on interval or time axis, that may allow you more flexibility.
see the sample JPG I posted in the response to the previous response
I don't see any code.
How you are summarizing data affects the options available.
What is your current raxis definition? Also you did not show whether your date varaible is actually a date or not. If your variable is not a date then the syntax for an AXIS statement, or the equivalent for SGPLOT is nastier.
And is the desire to show "one value per quarter" or "one tick mark per quarter with the month data as previous"? And what format should that tick value show: 01/2012, Jan 2012, 2012 Q1 or something else? Should the position be at the first, middle or last of a calendar quarter?
[Edited: Sorry, unsure how I got to open this old question 😕 ].
goptions xpixels=640 ypixels=200; data PLOT; format DATE monyy.; do DATE='01jan2011'd to '01jan2015'd by 31; output; end; run; proc gchart; vbar DATE /discrete ; run; quit; data _null_; set PLOT end=LASTOBS; if _N_=1 then call execute('axis1 value=('); call execute(quote(ifc(month(DATE) in(1,4,7,10),put(DATE,monyy.),' '))); if LASTOBS then call execute(');'); run; proc gchart; vbar DATE /discrete maxis=axis1; run; quit;
One thing I would recommend for this graph is using a 'grouped bar chart' (grouping by year).
That will clean up the axis a lot (rather than repeating the year in the label of each bar).
Here's a simple example that might be helpful:
data mydata; set sashelp.stocks (where=(stock='IBM' and date>='01jan2003'd));
goptions gunit=pct htitle=4 htext=2.25;
axis1 value=(angle=0) label=none;
axis3 label=none minor=none;
pattern1 v=s c=dodgerblue;
title1 "Stock price for IBM, by month";
proc gchart data=mydata;
format date month.;
format close dollar8.0;
vbar date / discrete type=sum sumvar=close
group=year nozero space=0 maxis=axis1 gaxis=axis2 raxis=axis3;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.