Dear Statalist Members,
I am truly confused about how to merge two different datasets. I have created an example of the master dataset and the other dataset, please see below. The datasets should be matched based on country names (variable named ctr_n). However, since the years are different (variable named yr), I cannot merge them.
I would be really happy if you can help me. Thank you in advance.
This is the master dataset:
This is the other dataset:
I am truly confused about how to merge two different datasets. I have created an example of the master dataset and the other dataset, please see below. The datasets should be matched based on country names (variable named ctr_n). However, since the years are different (variable named yr), I cannot merge them.
I would be really happy if you can help me. Thank you in advance.
This is the master dataset:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 ctr_n int yr str7 GADM_1 "Angola" 1992 "." "Angola" 1992 "." "Angola" 1992 "." "Angola" 1992 "." "Angola" 1992 "Bengo" "Angola" 1992 "Bengo" "Angola" 1992 "Bengo" "Angola" 1992 "Bie" "Angola" 1992 "Bie" "Angola" 1992 "Bie" "Angola" 1992 "Cabinda" "Angola" 1992 "Cabinda" "Angola" 1992 "Zaire" "Angola" 1992 "Zaire" "Angola" 1992 "Zaire" "Angola" 2008 "Bengo" "Angola" 2008 "Bengo" "Angola" 2008 "Bengo" "Angola" 2008 "Bie" "Angola" 2008 "Bie" "Angola" 2008 "Cabinda" "Angola" 2008 "Cabinda" "Angola" 2008 "Cabinda" "Angola" 2008 "Cabinda" "Angola" 2008 "Cabinda" "Angola" 2012 "Bengo" "Angola" 2012 "Bengo" "Angola" 2012 "Bengo" "Angola" 2012 "Bengo" "Angola" 2012 "Bengo" "Angola" 2012 "Bengo" "Angola" 2012 "Bengo" "Angola" 2012 "Bengo" "Angola" 2012 "Bengo" "Angola" 2012 "Cabinda" "Angola" 2017 "Bie" "Angola" 2017 "Bie" "Angola" 2017 "Zaire" "Angola" 2017 "Zaire" end
This is the other dataset:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 ctr_n int(yr refugeepop longitude latitude) str7 GADM_1 "Angola" 2000 545 . . "Bengo" "Angola" 2000 27 . . "Cunene" "Angola" 2000 1396 13234 -8812 "Luanda" "Angola" 2000 127 . . "Malanje" "Angola" 2000 5955 . . "Malanje" "Angola" 2000 79 . . "Moxico" "Angola" 2001 5 . . "Cunene" "Angola" 2001 610 13234 -8812 "Luanda" "Angola" 2001 476 . . "Luanda" "Angola" 2001 1 . . "Malanje" "Angola" 2001 6544 . . "Malanje" "Angola" 2001 752 . . "Malanje" "Angola" 2001 11 . . "Malanje" "Angola" 2001 3 . . "Malanje" "Angola" 2002 476 . . "Luanda" "Angola" 2002 610 13234 -8812 "Luanda" "Angola" 2002 11 . . "Malanje" "Angola" 2002 3 . . "Malanje" "Angola" 2002 1 . . "Malanje" "Angola" 2002 6544 . . "Malanje" "Angola" 2002 752 . . "Malanje" "Angola" 2003 11 . . "Malanje" "Angola" 2003 1 . . "Malanje" "Angola" 2003 7051 . . "Malanje" "Angola" 2003 3 . . "Malanje" "Angola" 2004 1 . . "Malanje" "Angola" 2004 7051 . . "Malanje" "Angola" 2004 3 . . "Malanje" "Angola" 2004 11 . . "Malanje" "Angola" 2005 7066 . . "Malanje" "Angola" 2005 11 . . "Malanje" "Angola" 2005 1 . . "Malanje" "Angola" 2005 3 . . "Malanje" "Angola" 2006 3 . . "Malanje" "Angola" 2006 1 . . "Malanje" "Angola" 2006 6217 . . "Malanje" "Angola" 2006 11 . . "Malanje" "Angola" . . . . "Luanda" end
Comment