BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DaveShea
Lapis Lazuli | Level 10

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:

DaveShea_2-1594893492662.png

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

 

DaveShea
Lapis Lazuli | Level 10
Hi BallardW,
Thanks for the pointer to SGPLOT. I suppose your solution is another reason to shift over to the even richer features that the SGxxx procs offer. I can now do my nice formatting and I've learned a whole new heap of things to boot.

Thanks.

Downunder Dave

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

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.

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
  • 2 replies
  • 718 views
  • 0 likes
  • 2 in conversation