The codebook command provides information about the variables in your dataset, including variable labels, value labels, and descriptive statistics. To use it, simply type codebook followed by a list of variables you want to check.
Before starting this exercise, you should have the “DataSet.dta” file. (Download link is given below)
Click here to download – “DataSet.dta”
Importing the “.dta” file
use"DataSet.dta"
Or
use "/Users/pankajchowdhury/Desktop/NFHS5/DataSet.dta"
I have the file located at “/Users/pankajchowdhury/Desktop/NFHS5/DataSet.dta”. Feel free to modify the file path according to your needs.
Results :
Observations | : 636,699 | |||
Variables | : 17 | |||
Variable name | Storage type | Display | Value label | Variable label |
hv005 | long | %12.0g | hv005 | household sample weight (6 decimals) |
hv024 | byte | %40.0g | HV024 | state |
hv206 | byte | %8.0g | HV206 | has electricity |
hv207 | byte | %8.0g | HV207 | has radio |
hv209 | byte | %8.0g | HV209 | has refrigerator |
Mobile | byte | %8.0g | HV243A | has mobile telephone |
Computer | byte | %8.0g | HV243E | has a computer |
sh48 | int | %21.0g | SH48 | what is the caste or tribe of the head of the household? |
Internet | byte | %8.0g | SH50N | internet |
HH_Owner | byte | %8.0g | SH61 | does this household own this house or any other house? |
Edu_Years | byte | %12.0g | Edu_Years | RECODE of hv108_01 (education completed in single years) |
Caste | byte | %9.0g | Caste | RECODE of sh49 (is this a scheduled caste,a scheduled tribe, other backward class) |
HH | byte | %9.0g | HH | RECODE of hv219 (sex of head of household) |
Religion | byte | %9.0g | Religion | RECODE of sh47 (what is the religion of the head of the household?) |
AgeGrp | byte | %9.0g | AgeGrp | RECODE of hv220 (age of head of household) |
BPC | byte | %9.0g | BPC | RECODE of BPL_Card (does this household have a bpl card?) |
HH_Type | byte | %10.0g | HH_Type | RECODE of HHType (house type (as defined in nfhs-2 and 3)) |
Code 1:
codebook
Or
codebook _all
Explanation :
codebook
andcodebook _all
– These commands are equivalent. This command will check the variable type, variable label, Range, Unique values, value label and frequency distribution of all variables.
Code 2:
codebook Religion
Explanation :
codebook Religion
– This command will check the variable type, variable label, Range, Unique values, value label and frequency distribution of a particular variable “Religion”.
Results :
Religion: | RECODE of sh47 (what is the religion of the head of the household?) | |||||
Type: | Numeric (byte) | |||||
Label: | Religion | |||||
Range: | [1,4] | Units: | 1 | |||
Unique values: | 4 | Missing .: | 0/636,699 | |||
Tabulation: | Freq. | Numeric | Label | |||
4,82,073 | 1 | Hindu | ||||
72,584 | 2 | Muslim | ||||
49,729 | 3 | Christian | ||||
32,313 | 4 | Others |
Code 3:
codebook sh*
Explanation :
codebook sh*
– This command will check the variable type, variable label, Range, Unique values, value label and frequency distribution of those variables starting with “sh”.
Results :
sh48 | what is the caste or tribe of the head of the household? | |||||
Type: | Numeric (int) | |||||
Label: | SH48 | |||||
Range: | [991,998] | Units: | 1 | |||
Unique values: | 4 | Missing .: | 0/636,699 | |||
Tabulation: | Freq. | Numeric | Label | |||
5,13,172 | 991 | 991 | enter caste | |||
91,856 | 992 | 992 | enter tribe | |||
27,640 | 993 | 993 | no caste / tribe | |||
4,031 | 998 | 998 | don't know |