* do e:\DHS\accidents_injuries\accidents_injuries_do_20Sep2024.txt * Stata program for analysis of accident and injury data in the Nepal 2022 DHS survey * Tom Pullum, tom.pullum@icf.com, September 2024 * Line number (hai10) is 0 if person is not in the hh, is . if died, except that there * are 3 cases where the person did not die but has line number=. * There are 16 people who had 2 accidents, 1429 who had 1 * Because of the 16 people with 2 accidents, there will be repeated cases in the merged file * Executable lines begin after multiple lines of asterisks ************************************************************************************* program define make_AI_file * Open Nepal 2022 HR file and construct an accidents and injury file * Only include the AI variables, plus hv001 hv002 hvidx use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\NPHR82FL.DTA" * see the list of ai variables *describe hai*_1 keep hv001 hv002 sha01 sha17 hai* save temp0.dta, replace clear set obs 1 gen dummy=1 save temp1.dta, replace * Instead of reshape, use append forvalues lai=1/5 { use hv001 hv002 sha01 sha17 hai*_`lai' using temp0.dta, clear rename hai*_`lai' hai* keep if hai1<. rename hai10 hvidx append using temp1.dta save temp1.dta, replace } drop if dummy==1 drop dummy * AI file is now complete except value labels include _5 * clumsy segment to remove _5 from the name of the label foreach v of varlist _all { local lbl:value label `v' scalar sbl="`lbl'" if regexm(sbl,"_5")==1 { scalar sblr=regexr(sbl,"_5","") local lblr=sblr label copy `lbl' `lblr' label values `v' `lblr' label drop `lbl' } } * Save with a different name than the official DHS version of the AI file gen cluster=hv001 gen hh=hv002 gen line=hvidx save NPAI82.dta, replace * save male and female versions, for merge with the IR and MR files use NPAI82.dta, clear keep if hai6==1 save NPAI82_M.dta, replace use NPAI82.dta, clear keep if hai6==2 save NPAI82_F.dta, replace end ************************************************************************************* program define AI_PR_merge use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\NPPR82FL.DTA", clear gen cluster=hv001 gen hh=hv002 gen line=hvidx merge 1:m cluster hh line using NPAI82.dta tab _merge save NPAIPR82.dta, replace end ************************************************************************************* program define AI_IR_merge use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\NPIR82FL.DTA", clear gen cluster=v001 gen hh=v002 gen line=v003 merge 1:m cluster hh line using NPAI82_F.dta tab _merge save NPAIIR82.dta, replace end ************************************************************************************* program define AI_MR_merge use "C:\Users\26216\ICF\Analysis - Shared Resources\Data\DHSdata\NPMR82FL.DTA", clear gen cluster=mv001 gen hh=mv002 gen line=mv003 merge 1:m cluster hh line using NPAI82_M.dta tab _merge save NPAIMR82.dta, replace end ************************************************************************************* ************************************************************************************* ************************************************************************************* ************************************************************************************* ************************************************************************************* * Executable lines begin here * Specify a workspace cd e:\DHS\DHS_data\scratch make_AI_file AI_PR_merge AI_IR_merge AI_MR_merge * Note that the merges with the IR and MR files include females and males who are out of * the usual age range