Skip to content

Commit 1b912a7

Browse files
committed
Update 2021, panel
1 parent fd432c9 commit 1b912a7

File tree

11 files changed

+17921
-0
lines changed

11 files changed

+17921
-0
lines changed

GLD/IND/IND_2017-2023_PLFS-Urban-Panel/IND_2017-2023_PLFS-Urban-Panel_V02_M/Programs/IND_2017.do

Lines changed: 2522 additions & 0 deletions
Large diffs are not rendered by default.

GLD/IND/IND_2017-2023_PLFS-Urban-Panel/IND_2017-2023_PLFS-Urban-Panel_V02_M/Programs/IND_2018.do

Lines changed: 2505 additions & 0 deletions
Large diffs are not rendered by default.

GLD/IND/IND_2017-2023_PLFS-Urban-Panel/IND_2017-2023_PLFS-Urban-Panel_V02_M/Programs/IND_2019.do

Lines changed: 2546 additions & 0 deletions
Large diffs are not rendered by default.

GLD/IND/IND_2017-2023_PLFS-Urban-Panel/IND_2017-2023_PLFS-Urban-Panel_V02_M/Programs/IND_2020.do

Lines changed: 2576 additions & 0 deletions
Large diffs are not rendered by default.

GLD/IND/IND_2017-2023_PLFS-Urban-Panel/IND_2017-2023_PLFS-Urban-Panel_V02_M/Programs/IND_2021.do

Lines changed: 1837 additions & 0 deletions
Large diffs are not rendered by default.

GLD/IND/IND_2017-2023_PLFS-Urban-Panel/IND_2017-2023_PLFS-Urban-Panel_V02_M/Programs/IND_2022.do

Lines changed: 1867 additions & 0 deletions
Large diffs are not rendered by default.

GLD/IND/IND_2017-2023_PLFS-Urban-Panel/IND_2017-2023_PLFS-Urban-Panel_V02_M/Programs/IND_2023.do

Lines changed: 2032 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
***************************************
3+
** Code for IND PLFS Urban Panel **
4+
** Master file that defines paths, **
5+
** calls other functions to do work **
6+
***************************************
7+
8+
* List files in folder
9+
filelist, dir("${path_input}") pat("*.dta")
10+
11+
* Create var that takes out survey core (i.e., without version numbers)
12+
gen survey_core = regexs(1) if regexm(filename, "(^[a-zA-Z][a-zA-Z][a-zA-Z]_[0-9][0-9][0-9][0-9]_[a-zA-Z0-9-]+)(_[vV][0-9][0-9]_M_[vV][0-9][0-9]_A)_([a-zA-Z][a-zA-Z][a-zA-Z]+)_([ALL]+)\.dta")
13+
14+
* By construction of the name (surveycore_v##_M_v##_A), the alphanumeric order will
15+
* put the most recent one last. Thus, surveycore_v01_M_v03_A is after surveycore_v01_M_v02_A,
16+
* both are before surveycore_v02_M_v01_A.
17+
18+
* We need to make sure the filename is entirely capitalized; otherwse, not sort properly
19+
replace filename = upper(filename)
20+
21+
sort filename
22+
egen survey_number = seq(), by(survey_core)
23+
egen survey_numb_max = max(survey_number), by(survey_core)
24+
keep if survey_numb_max == survey_number
25+
26+
* Create relevant variables to match
27+
gen country = substr(survey_core,1,3)
28+
gen years = substr(survey_core,5,4)
29+
gen survname = regexs(1) if regexm(survey_core, "^[a-zA-Z][a-zA-Z][a-zA-Z]_[0-9][0-9][0-9][0-9]_([a-zA-Z0-9-]+)")
30+
31+
* Keep relevant variables, save
32+
keep country years survname dirname filename
33+
34+
* Create variable for full name
35+
gen fullname = dirname + "/" + filename
36+
37+
levelsof fullname, local(year_files)
38+
clear
39+
foreach file of local year_files {
40+
41+
append using "`file'", force
42+
43+
}
44+
45+
* In the case of India, panel can only be formed using the urban sample
46+
keep if urban == 1
47+
48+
* Diagnostic: Check wave and visit consistency. For a given HH wave- visit_no should be unique. Only applies when visit_no is available.
49+
50+
capture confirm variable visit_no
51+
52+
if _rc == 0 {
53+
54+
gldpanel_wave_visit_check
55+
drop vw_tag
56+
57+
}
58+
59+
* Here there are 329,076 cases of individual-waves where the household-wave info is mapped to more than one visit_no. There are two possibilities: (1) visit is assigned based on individual appearance not the household's; (2) the hhid is not unique for a given round-year.
60+
61+
* Diagnostic: Check for re-use of HHID outside panel
62+
gldpanel_id_check
63+
64+
* The results above show that there is a prevalent re-use of HHIDs in non-subsequent years!
65+
* Also, there is a re-use of HHID within a year!
66+
* This means we cannot use HHID or PID to create the panel variable!
67+
68+
*save "${path_output}/paneldata_${country}.dta", replace
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
2+
***************************************
3+
** Code for IND PLFS Urban Panel **
4+
** Create the panel vars from the **
5+
** appended file **
6+
***************************************
7+
8+
*<_panel_>
9+
10+
capture confirm variable panel
11+
if _rc==0 {
12+
display "panel is already available in the data. Do not create"
13+
}
14+
else {
15+
16+
* Create panel variable out of visit numbers
17+
* Credits to Nils Enevoldsen for this code:
18+
destring wave, ignore("Q") gen(wave_num)
19+
20+
gen quarter_monotonic = wave_num + 8 * floor((year - 2017) / 2)
21+
22+
// Generate Panel ID, numbered as in PLFS documentation
23+
// This logic might break with future PLFS releases. In particular, it assumes that
24+
// the "tens place" increments every two rounds, and the "ones place" resets every
25+
// two rounds.
26+
tempvar tens ones
27+
gen `tens' = 1 + floor((quarter_monotonic - visit_no) / 8)
28+
gen `ones' = 1 + mod(quarter_monotonic - visit_no, 8)
29+
gen panel_num = `tens' * 10 + `ones'
30+
*tostring panel_num, gen(panel)
31+
32+
* Slight deviation from Nils, instead adopt panel nomenclature used in the report (which starts with P)
33+
gen panel = "P" +string(panel_num)
34+
35+
* Display unique panels and tabulate year and wave for each panel
36+
quietly levelsof panel, local(panels)
37+
foreach panel of local panels {
38+
display "* Displaying panel: `panel'",
39+
dis "This is panel: `panel'"
40+
tab year wave if panel == "`panel'"
41+
}
42+
}
43+
44+
45+
*drop wave_num panel_num
46+
*</_panel_>
47+
48+
*<_visit_no_>
49+
50+
capture confirm variable visit_no
51+
if _rc==0 {
52+
display "visit_no is already available in the data. Do not create"
53+
}
54+
55+
*</_visit_no_>
56+
57+
58+
*<_hhid_panel_>
59+
gen hhid_panel = hhid + panel
60+
label var hhid_panel "Household ID (panel)"
61+
*</_hhid_panel_>
62+
63+
64+
*<_pid_panel_>
65+
* Create PID variable adding panel information
66+
* First extract the individual number
67+
gen rosternum = substr(pid, -2, 2)
68+
gen pid_panel = hhid_panel + rosternum
69+
drop rosternum
70+
71+
isid pid_panel wave
72+
label var pid_panel "Person ID (panel)"
73+
*</_pid_panel_>
74+
75+
* Clean up
76+
77+
quietly{
78+
79+
drop quarter_monotonic
80+
order panel, before(visit_no)
81+
order hhid_panel, after(hhid)
82+
order pid_panel, after(pid)
83+
84+
}
85+
86+
* Diagnostic: Check for re-use of HHID outside panel
87+
gldpanel_id_check, hhid(hhid_panel) pid(pid_panel)
88+
89+
* Check panel formation - if needed
90+
/*
91+
levelsof panel, local(panels)
92+
foreach panel of local panels {
93+
94+
dis "This is panel: `panel'"
95+
tab year wave if panel == "`panel'"
96+
97+
}
98+
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
***************************************
3+
** Code for IND PLFS Urban Panel **
4+
** Assess Panel Quality **
5+
***************************************
6+
7+
8+
*---------- Age sex matches ------------------------------*
9+
*gldpanel_issue_check, hhid(hhid_panel) pid(pid_panel)
10+
*graph export "${path_work}/age_sex_matches.png", replace
11+
12+
*---------- Sources of mismatch ------------------------------*
13+
gldpanel_check_source, hhid(hhid_panel) pid(pid_panel)
14+
graph export "${path_work}/source_mismatches.png", replace
15+
16+
*---------- PID Attrition ------------------------------*
17+
* Case of India, change wave so that it runs in sets of four
18+
gen tempwave = wave
19+
replace tempwave = "Q1" if wave == "Q5"
20+
replace tempwave = "Q2" if wave == "Q6"
21+
replace tempwave = "Q3" if wave == "Q7"
22+
replace tempwave = "Q4" if wave == "Q8"
23+
24+
gldpanel_attrition, hhid(hhid_panel) pid(pid_panel) wave(tempwave) consecutive_waves
25+
graph export "${path_work}/attrition_consecutive_waves.png", replace name(Graph)
26+
27+
gldpanel_attrition, hhid(hhid_panel) pid(pid_panel) wave(tempwave) any_wave
28+
graph export "${path_work}/attrition_any_wave.png", replace
29+
30+
gldpanel_attrition, hhid(hhid_panel) pid(pid_panel) wave(tempwave) all_waves
31+
graph export "${path_work}/attrition_all_waves.png", replace
32+
33+
cap drop tempwave

0 commit comments

Comments
 (0)