Hi to all,
I've got the 2 following questions:
1) I've to plot a gchart, where the hbar variable is numeric, and I've applied a format to show it. However, I need to put the values in descending order, but I couldn't find any way to do it (I cannot specify all the values, because the format does regroup the values)...any idea?
2) I've been asked to put the vertical legend in the center of the graph, where the value is 0...I should use the annotate, but how?
It will order the bars in descending order. For example, both HBAR statements will generate bars in descending order:
proc gchart data=sashelp.class;
hbar age /levels=6 descending ;
hbar age / discrete descending;
I'm not sure I understand what you mean by vertical legend?? You mean the position of the statistics?? Or are you using SUBGROUP= that has a legend??? The SUBGROUP legend can be controlled by the LEGEND statement.
I've tried the descending option, but I believe it works with the sumvar variable, and not the hbar one (in fact, I get some weird ordered diagram, but which is ordered by the sum of the positive values and negative values of the sumvar variable)...I'm pretty sure of the format I'm using, since it's quite simple...
Based on your vertical axis question, It seems that you have negative and positive values. Proc GChart HBar will automaitically place the vertical axis at zero.
input a $ b;
thank you for your kind answer, but I believe I didn't express myself correctly: what I want is the legend of the vertical axes in the center of the graph (normally is on the left, since this is a hbar graph). Is it possible?
If the axis values are already known, the simpliest approach it to specify the values on the MIDPOINTS= option in descending order. If they are no known, there are some techniques for generating this midpoint list dynamically using a macro.
I'm not sure of what you have explained on your post...how I should use midpoints?
Let me explain my dataset: I've got values for all the range of different ages from 0 to over 80 years, and I've to plot the values on a hbar diagram, where:
1) I've applied a format for the age, which groups the ages in 5 years segments (0-4 years, over 80 years old, and so on)
2) I'd like to show this diagram in this order:
80 years and over old
75 to 79 old
0 to 4 years old
3) This legend (which are the ages formatted) should be pun in the center of the graph, where tha value is 0 (the fact is that I've got also negative values, and the legend is at the left of the negative).
Hi to all,
for the first problem, I've solved by proc tabulating first with the format, and outputting the results in a dataset, that I've used with the proc gchart. In this way I've got one observation for class, and it's easy to order it as I want.
For the second point...yes Chris, I mean the axis1 legend...
This should get you started:
XSYS = '5'; * X coordinates use % of graphics output area ;
YSYS = '2'; * Y coordinates use data values ;
FUNCTION = 'label'; * I want to write a string;
TEXT = 'My label'; * This is the string;
X = 5; * Write at position X=5 (% of graphics output area);
Y = 0; * Write at Y=O (data value);
axis1 label=(c=red 'free up space, should be white' );
proc gchart data=T annotate=ANNO;
hbar AGE / discrete nostats maxis=axis1;