Support #1621
openHow to merge two data files from two different waves?
100%
Description
Could you please provide me with stata syntax to merge 'j_indresp.dta' and 'k_indresp.dta' into one file ?
I need to merge the two files for descriptive statistics about the participants status from 2018 to 2020?
thanks in advance
Amwaj
Updated by Understanding Society User Support Team about 3 years ago
- Status changed from New to Feedback
- % Done changed from 0 to 80
- Private changed from Yes to No
Hello,
(1) Merge into a wide format file, and you only want to keep those who appeared in both datasets
use j_indresp, clear
merge 1:1 pidp using k_indresp, nogen keep(3)
(2) Merge into a wide format file, and you want to keep all those who appeared in either datasets
use j_indresp, clear
merge 1:1 pidp using k_indresp, nogen
(3) Merge into a long format file, and you only want to keep those who appeared in both datasets
use j_indresp, clear
rename j_*
g wave=10
save j, replace
use k_indresp, clear
rename k_ *
g wave=11
append using j
bys pidp: keep if _N==2
(4) Merge into a long format file, and you want to keep all those who appeared in either datasets
use j_indresp, clear
rename j_*
g wave=10
save j, replace
use k_indresp, clear
rename k_ *
g wave=11
append using j
Best wishes,
Understanding Society User Support Team
Updated by Understanding Society User Support Team almost 3 years ago
- Status changed from Feedback to Resolved
- Assignee deleted (
Alita Nandi) - % Done changed from 80 to 100
Updated by Understanding Society User Support Team over 1 year ago
- Category changed from Data analysis to Data management