Introduction
The codebook command in Stata is an easy way of learning a lot about the characteristics of a variable. In this blog, we’ll show you how to use and understand the codebook command in the context of a real Stata dataset.
Load Dataset
Let’s call up this built-in dataset on demographics:
sysuse nlsw88
describe
Codebook Command
The following command will generate a so-called codebook for each variable in the study:
codebook
However, you can also isolate a specific variable or variables for analysis. Let’s generate codebooks on the two variables of married and race:
codebook married race
Examine the Results
Let’s start by taking a look at the codebook for the married variable:
The top left tells you that the name of the variable in Stata is married. However, the top right tells you that the variable married has been given the label of "Married." If the top right also said married, you could use the following code: in Stata to change the label to sentence case:
label variable married "Married"
Next, you can see that are 2,246 values for married in this dataset, and there are no missing values. Married ranges from 0 to 1, and codebook tells you that 0 = single, 1 = married. You even have frequency counts for the numbers of single and married people in the dataset.
Now check the codebook results for race:
As you can see, there are also 0 missing values for race among 2,246 responses, and there is other pertinent information about this variable disclosed by the codebook command.
BridgeText can help you with all of your statistical analysis needs.