Course sections

Introduction to Analytics, Lecture 5

Graphical summary using SAS/GRAPH: Introduction to Pie graph

What is a Pie Chart?
A pie chart is a circular chart divided into wedge-like sectors, illustrating proportion. Each wedge represents a proportionate part of the whole, and the total value of the pie is always 100 percent. Pie charts can make the size of portions easy to understand at a glance. They’re widely used in business presentations and education to show the proportions among a large variety of categories including expenses, segments of a population, or answers to a survey.

Pie Chart vs Bar Chart
Some critics of pie charts point out that the portions are hard to compare across other pie charts and if a pie chart has too many wedges, even wedges in a single pie chart are hard to visually contrast against each other compared to the height of bars in a bar graph for example. Bar charts are easier to read when you’re comparing categories or looking at change over time. The only thing bar charts lack is the whole-part relationship that makes pie charts unique. Pie charts imply that if one wedge gets bigger, the other has to be smaller. This would not be true of two bars on a bar chart.

Let’s now see how we can create different types of pie charts in SAS.
PROC GCHART DATA= mylib.CANDY_SALES_SUMMARY;
PIE3D SUBCATEGORY;
RUN;
QUIT;

This code generates a 3-dimensional pie-chart using the option pie-3d. Gchart is used to procedure the graphical chart. The pie-chart represents each of the subcategory on a pie, i.e. as a percent-age of 360 degrees. We are creating a pie chart for each of the different subcategory of candies present in the data set called “Candy_Sales_Summary”. “mylib” is the name of the library which stores all the SAS data sets.

If we modify the above code like:
PROC GCHART DATA= mylib.CANDY_SALES_SUMMARY;
PIE SUBCATEGORY/ VALUE= INSIDE;
RUN;
QUIT;

We will get a variation of the previous pie chart representation, value=inside keeps the frequency values in the slices along with the names of the subcategory. Each of the sub-category is shown in slices of different colors. Note: We have not mentioned the keyword “3D” here and hence we would get a 2-dimensional pie chart, which is the default type of chart in SAS. The code below is for a pie chart which puts out the frequency of sale corresponding to the sale subcategory. The percentage frequency of the sale and the discrete value of the sale of the subcategory are shown outside and the name of the variable is shown outside the slice.

PROC GCHART DATA= mylib.CANDY_SALES_SUMMARY;
PIE3d SUBCATEGORY/ VALUE=INSIDE
PERCENT=INSIDE
SLICE=OUTSIDE
FREQ=SALE_AMOUNT;
RUN;
QUIT;

On running the above code, we will get a graph like the one shown below

WhatsApp chat