01-17-2017 03:25 PM
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?
01-17-2017 03:34 PM
What do you mean by:
but only have quarterly values appear on the horizontal axis
Are you looking to change the aggregation from monthly to quarterly or to just change the labels on the axes?
01-17-2017 03:42 PM
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.
01-17-2017 03:57 PM
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.
01-17-2017 04:12 PM
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.
01-17-2017 04:15 PM
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?
02-16-2017 05:05 PM - edited 02-16-2017 05:11 PM
[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;
02-15-2017 09:45 AM
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;