Project

General

Profile

Support #1621

How to merge two data files from two different waves?

Added by amwaj abugamza 5 months ago. Updated 4 months ago.

Status:
Resolved
Priority:
High
Assignee:
-
Category:
Data analysis
Start date:
12/13/2021
% Done:

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

#1

Updated by Understanding Society User Support Team 5 months 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

#2

Updated by Understanding Society User Support Team 4 months ago

  • Status changed from Feedback to Resolved
  • Assignee deleted (Alita Nandi)
  • % Done changed from 80 to 100

Also available in: Atom PDF