Click here to see the SAS code.
Click here to see the example.
I intentionally chose to try to imitate this J.D. Power chart (see p. 3),
because it is somewhat challenging to do in SAS.
(But now that you have my code, you can easily re-use it with your own data :)
This would be a normal/simple descending bar chart, except for the
special additional bar at the bottom (for USAA) and the response axis
positioned at the top. But those 2 things require some tricks...
In order to get the extra bar at the bottom, I am not using the built-in
descending option. Rather I am ordering the main bars data set, and then
adding an observation for the blank space/bar, and then adding one for the
USAA bar - then I assign an ordered numberic value to each obsn, and use
that as the midpoint for my hbars. I use value=none in the axis statement
to suppress these numbers, and I then annotate the company names into that
Since 'outside=sum' is not supported in hbar, I annotate the numbers
at the ends of the bars.
Since hbar only does the numeric/response axis at the bottom, I suppress
that axis in the axis statement, and annotate my own axis line, tickmarks,
and value labels at the top of the graph. I also annotate the dashed
line between USAA and the other bars.
Notice in my annotations that I use several different xsys/ysys
coordinate systems to position the various different kinds of
annotation exactly where they should be.
A couple of improvements over the original chart:
I added html charttips and drilldowns to the bars (click on a bar
and it will do a google web search on that insurance company's
Also, I like stopping the dashed line at the axis.
And, I made the top axis numeric values gray, so they don't compete
with the company names and values at the end of the bars.
Notice that there are 2 versions of this plot - the first version is
very much like the original, and the 2nd version puts the labels inside
the bars, uses a refline at the average value (so you can easily see
how much each bar is above/below the average), and the average bar
is red (so it stands out more).
Back to Samples Index