Data visualization with SAS programming

SAS Graph - Axis Question

Reply
Occasional Contributor
Posts: 13

SAS Graph - Axis Question

Guys -

If i have a Graph with values say;

a
60
70
60
100
120
110


I plot these on a bar graph with a on the Y Axis - is there a way i can format the axis to show the minimum at 40?

IS this possible at all?
SAS Employee
Posts: 967

Re: SAS Graph - Axis Question

By default, gchart included zero in the response axis, and it is generally the "best practice" to do that.

SAS does provide a way to over-ride the default with an axis statement (but make sure this is really/really/really sure this is what you want to do, and is a good way to display your data, before doing it!)


data foo;
barnum=_n_;
input a;
datalines;
60
70
60
100
120
110
;
run;

axis1 order=(40 to 150 by 10);
proc gchart data=foo;
vbar barnum / discrete
type=sum sumvar=a raxis=axis1;
run;
SAS Super FREQ
Posts: 889

Re: SAS Graph - Axis Question

Just in case your using SGPLOT for this, I modified Robert's example to show you how you would do it.

[pre]
data foo;
barnum=_n_;
input a;
datalines;
60
70
60
100
120
110
;
run;

proc sgplot data=foo;
yaxis min=40;
vbar barnum / response=a;
run;
[/pre]
Super Contributor
Posts: 291

Re: SAS Graph - Axis Question

Ace:

Rob is letting you off easy with respect to the bar chart not startng at zero. Here's why it must start at zero:

Bar Chart Value Axis Scale Must Include Zero
by Jon Peltier
Wednesday, March 30th, 2011
Peltier Technical Services, Inc., Copyright © 2011.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

http://peltiertech.com/WordPress/bar-chart-value-axis-scale-must-include-zero/#ixzz1OF1FUIkt.

Remember the cardinal rule about bar charts and axis scales? Because we judge the values in a bar chart by the lengths of the bars, not by the positions of the ends of the bars, the axis scale must include zero. By chopping off the bottoms of the bars, we increase the resolution of the chart, but we distort the apparent values encoded by the bars. I’ll repeat: The value axis of a bar chart must include the value zero.

Bill
Ask a Question
Discussion stats
  • 3 replies
  • 166 views
  • 0 likes
  • 4 in conversation