Joining Data with Stata
Stata offers several commands for joining datasets.
Full Join
If the left and right datasets may overlap, use the merge command to ensure that duplicates are not created.
use "left.dta" merge 1:1 KEYVARS using "right.dta"
If they are known to not overlap, the append command can be used instead.
use "cohort1.dta" append using "cohort2.dta"
See also the frlink command.
Left Join
Use the merge command as above and select cases based on the created _merge variable.
use "left.dta" merge 1:1 KEYVARS using "right.dta" keep if _merge==1 | _merge==3
Alternatively, try using the keep(groups) option.
use "left.dta" merge 1:1 KEYVARS using "right.dta", keep(1 3)
See also the frlink command.
Right Join
As with the left join, but the groups of interest are 2 and 3.
Inner Join
As with the left join, but only group 3 is of interest.