I almost have my hbar chart where I need it to be, with the following exceptions:
1) My bars are "stacked" using a subgroup variable - I have each subroup labeled with its percent value. However, I cannot figure out how to get the percent value centered within its area of the bar. Here is the code used to label the subgroups - I have the code "annotate=barlabel" as an option in my hbar statement:
data barlabel; length color style $ 8; retain color 'black' when 'a' style 'swissb' xsys ysys '2' position '[less than sign]' size 2 hsys '3'; set stats;
*Note: I needed to indicate the "less than" sign with words above because otherwise it would cut my post short.
2) I cannot, for some reason, change the label or values of the vertical axis - I am trying to change the font and use right justify, but nothing happens. Here is the rest of the code I am using:
I modified your test to use sashelp.class, just as an example. The key do doing what you want is to use proc summary to pre-compute your data and use X and Y in the annotate dataset instead of MIDPOINT and SUBGROUP. That way, you can compute the label locations based on the summarized data. Here the example:
proc summary data=sashelp.class nway;
class age sex;
output out=class sum=;
length color style $ 8;
retain color 'black'
xsys ysys '2'
if (last.age) then previous=0;
Dan, I can't thank you enough for your reply. I now have the labels centered on the corresponding bars.
However, I am running into a problem because my variable that is like "age" in your example is a categorical variable and I can't figure out how to label it with words. It has to be numerical to make your solution to the centered numbers work.
There must be something wrong with my axis code?
What is the vertical axis on my horizontal bar chart called? Is there a way to format the numbers to words? I apologize if I am not explaining this clearly...
If your midpoint data is strings, create a numeric column that assigns a numbers to the strings. Then, create a user-defined format that maps the numbers back to strings. Use the numeric column in the datastep and in the gchart procedure, using a FORMAT statement in the GCHART procedure to assign the format to your numeric column.