- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have a bar chart of the following look:
produced with the following code:
PROC GCHART DATA=MyData
;
VBAR
year_month
/
SUMVAR=count
SUBGROUP=segment
CLIPREF
FRAME TYPE=SUM
LEGEND=LEGEND1
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
LREF=1
CREF=BLACK
AUTOREF
;
run;
quit;
Any ideas on how I can produce the same bar chart BUT with the horizontal axis for each month (not midpoint of multiple months).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
No idea unless we can see your data that goes into this bar chart, although I am guessing that your variable year_month is not really a SAS date value. Please provide a portion of the data as WORKING data step code.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hopefully someone knows how to do it, if not I will have to try do some replicating example since I am using data from a database that is not available straight away.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data fake;
do month = 1 to 16;
date=intnx('month','01JAN2020'd,month,'b');
count=round(rand('uniform',0,100));
type='Mammal';
output;
count=round(rand('uniform',0,100));
type='Lizard';
output;
end;
format date yymmn4.;
run;
proc sgplot data=fake;
vbar date/group=type response=count groupdisplay=stack;
run;
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately with the very old GCHART procedure you have to show us the definitions of any AXIS, SYMBOL or Pattern statements you are using.
The AXIS1 definition controls the values of your horizontal axis from the code you show. To change the VALUES displayed for the tickmarks you would need to modify that definition with an ORDER= showing the values that you want.
Perhaps: Order=('01JAN2021'd to '01Jan2023'd by month)
Your months should indicate the dates, as a date literal as shown above, for the months that you want displayed. One of the nice things with SAS and use of actual date values is the option to use the BY <interval name> option to indicate the first of the month, quarter, year or what have you (time and datetime values allow other intervals like hour).
Or in the example that @PaigeMiller a similar XAXIS statement:
xaxis values=('01JAN2021'd to '01Jan2023'd by month)
The Xaxis and Yaxis statements in the newer, usually much more flexible Sgplot, control the appearance of the axis instead of the remote often forgotten AXISn statements.