360Studies

360 Studies.com Logo

Your Destination for Career Excellence in Bioscience, Statistics, and Data Science

Codebook command in STATA

codebook-command-in-stata

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 nameStorage typeDisplayValue labelVariable label
hv005long%12.0ghv005household sample weight (6 decimals)
hv024byte%40.0gHV024state
hv206byte%8.0gHV206has electricity
hv207byte%8.0gHV207has radio
hv209byte%8.0gHV209has refrigerator
Mobilebyte%8.0gHV243Ahas mobile telephone
Computerbyte%8.0gHV243Ehas a computer
sh48int%21.0gSH48what is the caste or tribe of the head of the household?
Internetbyte%8.0gSH50Ninternet
HH_Ownerbyte%8.0gSH61does this household own this house or any other house?
Edu_Yearsbyte%12.0gEdu_YearsRECODE of hv108_01 (education completed in single years)
Castebyte%9.0gCasteRECODE of sh49 (is this a scheduled caste,a scheduled tribe, other backward class)
HHbyte%9.0gHHRECODE of hv219 (sex of head of household)
Religionbyte%9.0gReligionRECODE of sh47 (what is the religion of the head of the household?)
AgeGrpbyte%9.0gAgeGrpRECODE of hv220 (age of head of household)
BPCbyte%9.0gBPCRECODE of BPL_Card (does this household have a bpl card?)
HH_Typebyte%10.0gHH_TypeRECODE of HHType (house type (as defined in nfhs-2 and 3))

Code 1:

codebook

Or

codebook _all

Explanation : codebook and codebook _allThese 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:4Missing .:0/636,699
Tabulation:Freq.NumericLabel
4,82,0731Hindu
72,5842Muslim
49,7293Christian
32,3134Others

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 : 

sh48what is the caste or tribe of the head of the household?
Type:Numeric (int)
Label:SH48
Range:[991,998]Units:1
Unique values:4Missing .:0/636,699
Tabulation:Freq.NumericLabel
5,13,172991991enter caste
91,856992992enter tribe
27,640993993no caste / tribe
4,031998998don't know

Looking for latest updates and job news, join us on Facebook, WhatsApp, Telegram and Linkedin

You May Also Like

Scroll to Top