Getting Started in Stata - Creating a Histogram
Today we are going to show you how to create a histogram graph using both Stata menus and Stata commands. Graphics are an important tool for communicating data and results to others, as well as illustrating trends. The histogram graph is commonly used to display frequency distributions of a variable. The frequency can be measured by count, percentage, or density in Stata.
As a new Stata user it is recommended that you start by using the Stata menus to perform your analysis and create graphs. Each analysis or graphic, such as a t-test or scatter graph, will show up in your Review pane (on the left side of the Stata screen) as the equivalent Stata command. This allows you to begin learning the general structure of commands and how to use them. Once you become more familiar with commands you will find it is faster and easier to perform your analyses using commands.
I am going to use the Stata Example dataset auto.dta. I load this dataset using the following command:
Histogram using Stata Menus:
Graphics > Histogram
Select “rep78” from the “Variable:” drop-down menu
Select “Data are discrete” next to the “Variable:” drop-down menu
Select “Percent” from the list under the “Y axis” heading
Histogram using Stata Commands:
The rep78 variable shows the repair record of all cars in the dataset. This is over a repair record scale of 5, with 1 indicating a very poor repair record and 5 indicating an excellent repair record. This histogram tells us the majority of cars (over 40%) are recorded at 3, indicating these cars have average repair records. Less than 5% of cars have a very poor repair record of 1, and just over 15% of cars have an excellent repair record of 5.