Pie chart

Quick facts

Number of variables
One

Scales of variable(s)
Categorical (nominal)

Information

Similar to a bar chart, a pie chart can also be seen as a simple illustration of a frequency table.

The slices represent the different values (or categories) of the variable and they can be specified in terms of the percentage of individuals in each category or the number of individuals in each category.

This function is used only for categorical variables (preferably nominal, since it makes more sense to illustrate non-ranked values with slices than with bars).

It is also recommended that the variable has relatively few categories – otherwise the pie chart will get too complex.

Function

Basic command
graph pie, over(varname)
Useful options
graph pie, over(varname) plabel(_all percent)
Explanations
varnameInsert the name of the variable you want to use.
plabel(_all percent, format(%12.1fShow the percentage distribution on the slices, with one decimal.
More information
help graph pie

Practical example

Dataset
StataData1.dta
Variable namemarstat40
Variable labelMarital status (Age 40, Year 2010)
Value labels1=Married
2=Unmarried
3=Divorced
4=Widowed
graph pie, over(marstat40)

The figure above is a pie chart for the variable marstat40.

It is rather easy to see that the category “Married” is the most common category (51.8%), followed by “Unmarried” (27.5%), “Divorced” (19.8%), and “Widowed” (1%).

We can also add the percentage of individuals in each category, by using the command plabel. Here, the command is specified so that the percentage shows inside each slice (formatted to display one decimal):

graph pie, over(marstat40) plabel(_all percent, format(%12.1f))

Note
You can use the Graph Editor (see Graph) to edit the pie chart.