Append data

One way of combining data is to add additional observations, e.g., data from other individuals or countries:

append

Append data

******************************
*** append, merge & joinby ***


/*
"append", "merge" & "joinby" can be used to combine datasets
*/


*** append ***


* Load & inspect first data set

use "household_members_south.dta", clear

describe
summarize
browse
// 155 observations, all from "south", several members per household

// To understand the dimensions of the data set: 
// Check whether hhhid+member uniquely identify the observations
isid hhid member


* Load & inspect second data set

use "household_members_north.dta", clear 

describe
summarize
browse
// 132 observations, all from "north", several members per household

isid hhid member


// We would like to add observations from the south to the north dataset
// --> use append 

append using "household_members_south.dta", gen(source)

// Always check the results
describe
summarize

/*
Note that missing variables in one dataset is set to missing for the other.
Make sure that variables in both datasets have same units/categories 
classification before appending!
*/

save "household_members_all.dta", replace 		// save data