The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Data » Merging data files » Merging and appending data files (I would like to 1) append data files of different countries and survey waves, 2) merge hh characteristics and coordinates to individuals)
Re: Merging and appending data files [message #28481 is a reply to message #28477] Tue, 16 January 2024 12:12 Go to previous message
Bridgette-DHS is currently offline  Bridgette-DHS
Messages: 3230
Registered: February 2013
Senior Member
Following is a response from Senior DHS staff member, Tom Pullum:

The following lines show how to append the IR files from these three surveys. Note that v024 (region), which is an important variable, is coded differently in the three surveys. It is just one example of a variable that is defined differently in the three surveys. Such variables must be saved with survey-specific variable labels and then be recoded to a single variable that applies across the surveys.

* Specify a workspace
cd e:\DHS\DHS_data\scratch

use "...\PKIR52FL.DTA", clear
keep v*
rename v024 v024_1
gen survey=1
save PKIR.dta, replace

use "...\PKIR61FL.DTA", clear 
keep v*
rename v024 v024_2
gen survey=2
quietly append using PKIR.dta
save PKIR.dta, replace

use "...\PKIR71FL.DTA", clear 
keep v*
rename v024 v024_3
gen survey=3
quietly append using PKIR.dta
save PKIR.dta, replace

tab1 v024_*

* You must construct a new variable for v024 (region) because the codes were different
*   in the three surveys.  Many other variables are also different in the three surveys
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Child nutrition and spousal violence
Next Topic: How to link child health outcome with mothers' characteristics
Goto Forum:
  


Current Time: Sat May 3 18:43:22 Coordinated Universal Time 2025