Quick facts
Number of variables
One
Scales of variable(s)
Categorical (ordinal)
Information
A bar chart is like an illustration of a frequency table.
On the x-axis (horizontal axis) you see the different values (or categories) of the variable and on the y-axis (vertical axis) you can choose to see either the percentage of individuals in each category (like in the graph below) or the number of individuals in each category.
As mentioned above, the bar chart is useful primarily for categorical variables (preferably ordinal, since the bars suggest that values are ranked) but can be used for any type of variable as long as it does not have too many values.
Function
| Basic command |
|
| Explanations | |
| Insert the name of the variable you want to use. |
More informationhelp graph bar |
Practical example
| Dataset |
| StataData1.dta |
| Variable name | educ |
| Variable label | Educational level (Age 40, Year 2010) |
| Value labels | 1=Compulsory 2=Upper secondary 3=University |
graph bar, over(educ) |

The figure above is a bar chart for the variable educ.
On the y-axis (vertical axis) we have percentages, and on the x-axis (horizontal axis), we have the different categories of the variable.
It is rather easy to see that the category “Upper secondary” is the most common category, followed by “University” and then “Compulsory”.
We can also add the percentage of individuals in each category, by using the command blabel. Here, the command is specified so that the percentage shows above each bar (formatted to display one decimal):
graph bar, over(educ) blabel(bar, position(top) format(%9.1f)) |

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