Hi,
I have a simple horizontal bar chart that I want to use to demonstrate something to a colleague.
The following is from SAS 9.4TSM6 via SAS Enterprise Guide 8.2 (Update 2)
The chart looks like this:
I would like to format the FREQUENCY statistic on the horizontal axis without resorting to creating an additional variable in the data used by the chart. I know that if I create a new column in the dataset and assign that a value of 1 on each row I can then use that new column in a SUMVAR= option on the HBAR statement and then use a simple FORMAT state in the Proc GCHART, but at this stage I do not want to do that as I am sure there is something already built in to Proc GCHART.
All I really want to do, at this stage is assign commas as thousand separators to the FREQUENCY values (e.g.4000 would appear as 4,000). If I got really lucky I would like to assign % signs to the PCT statistic on the outside right axis.
I started this off in the Bar Chart Task in SAS Enterprise Guide 8.2, and thought one of the magic controls in the Task would allow me to control this element of the chart. If it can, I must have overlooked it. I've since pinched the code out of the task and tidied it up.
I had thought that the AXIS statement might help, but I cannot find anything there. I have experimented with setting the output graphics type to PNG and JPEG in case this was one of those weird ActiveX things, but no joy.
At the end of this post, I have inserted the SAS code to generate the inflated WORK.SHOES dataset and the above chart.
Does anyone have any clues on this ?
Also, I am a bit intrigued as to why I see the WARNING message in the SASLOG:
WARNING: INSIDE=, OUTSIDE=, and SUBOUTSIDE options will be ignored for HBAR charts.
when the OUTSIDE=PCT that I specify is clearly not being ignored.
Cheers,
Downunder Dave.
Wellington
SAS Code follows
***************************************************************************;
*Beef up the standard SASHELP.SHOES dataset so that we have LOTS of rows. ;
***************************************************************************;
Data SHOES;
Set SASHELP.SHOES;
RollDice=Int(RanUni(6926656)*250)+1;
Do i=1 To RollDice;
Duration=Int(RanUni(4624286)*370)+1;
Output;
End;
Run;
***************************************************************************;
*Define the Axes we require. ;
***************************************************************************;
Axis1 STYLE=1
WIDTH=1
;
Axis2 STYLE=1
WIDTH=1
MINOR=NONE
;
Title1 "Frequency of Sales by Region";
**************************************************************;
*Now produce our lovely chart. ;
**************************************************************;
PROC GCHART DATA=WORK.SHOES;
HBAR Region / CLIPREF
FRAME
TYPE=FREQ
OUTSIDE=PCT
COUTLINE=BLACK
MAXIS=AXIS1
RAXIS=AXIS2
;
Run;
Quit;
The first thing to do when wanting to change the appearance of a value is to specify an appropriate format for the variable. For commas in the values use something like COMMA6.
Which with SGPLOT an the XAXIS statement you can actually apply with a VALUESFORMAT option.
When GCHART was all we had I usually summarized the data so that I could control appearance because the defaults with the FREQ or SUM statistics in the bar charts always did something I didn't like, such as Axis appearance.
I strongly suggest moving to SGPLOT.
The first thing to do when wanting to change the appearance of a value is to specify an appropriate format for the variable. For commas in the values use something like COMMA6.
Which with SGPLOT an the XAXIS statement you can actually apply with a VALUESFORMAT option.
When GCHART was all we had I usually summarized the data so that I could control appearance because the defaults with the FREQ or SUM statistics in the bar charts always did something I didn't like, such as Axis appearance.
I strongly suggest moving to SGPLOT.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.