Pie charts have been the subject of some criticism when they are used to compare measures across multiple categories. It is generally accepted that comparison of magnitudes represented as angular measures from varying baselines is not effective.
However here are some use cases where a pie chart does quite well.
When it comes to comparing one category to the whole population, IMHO, a pie chart does a good job for a part-to-whole comparison. In the examples above, even without the numbers one can see that Sedans have a little over 50% of the market, while SUV's have a smaller fraction.
Note: It helps if the centerline of the two slices has a vertical or horizontal orientation.
The SGPLOT procedure does not support pie charts, and most users are just fine with that. However SAS 9.3 GTL (Graph Template Language) that forms the underpinnings of the procedure does support pie charts. So, we could write a macro to create some pie charts.
I started with a simple macro, but soon the scope began to expand. So, I decided to stop and publish what I had. Once again, it is not bullet proof, nor tested, but a start.
Given the data set name, the category variable, and optionally a response or group variable and a few other options, this macro will output a nice pie chart to the open ODS destination(s).
The macro invocation for the left graph above is as follows:
%GTLPieChartMacro(data=GTL_Sedans, category=type, response=count, title=Share of Market for Sedans, startangle=340, DataLabelFontSize=12, responselabel=true, percentlabel=false);
By default, pie slices are drawn counterclockwise starting from the 3 o'clock position . For the pie charts shown above, we have used the startangle option to re-orient the pie. Such alignment clearly helps in decoding the information. I like the vertical alignment better than the horizontal, maybe because it is closer to the clock dial.
Here is the same pie chart with the default start angle. Not as satisfactory as the one above, I think.
When the pie has more than two slices, things get murky. Here are some examples using the macro. As the number of pie slices increase, or we add other features like groups, the effectiveness of the Pie Chart decreases.
%GTLPieChartMacro(data=sashelp.prdsale, category=product, response=actual, dataskin=gloss, title=Actual Sales by Product, footnote=Data Set: SAShelp.prdsale, footnotefontsize=6);
The "Other" slice kicks in by defalt to limit the number of slices as shown above.
%GTLPieChartMacro(data=sashelp.cars, category=make, dataskin=gloss, title=Share of Market by Make, footnote=Data Set: SAShelp.cars, responselabel=false, percentlabel=true, footnotefontsize=9, datalabelfontsize=6);
%GTLPieChartMacro(data=sashelp.prdsale, category=product, response=actual, group=year, dataskin=gloss, groupgap=10, title=Actual Sales by Product and Year, footnote=Data Set: SAShelp.prdsale, footnotefontsize=9, datalabelfontsize=6);
When the Pie chart has only two slices, I believe the default orientation of the centerline of the slices should be vertical. With some more coding, this can be added to the macro. Also for GTL, we intend to make this the default orientation at some point in the future. Your opinions are welcome.
Your turn: Do you find Pie Charts useful in your work, and have you tried the SAS 9.3 GTL Pie Chart?
SAS 9.3 GTL PieChartMacro: GTLPieChartMacro