Hello, im working with a panel data of exports between one country and others. Each product have a unique code for 4 years. So we have a code for the period of 2017 to 2012 . 2012 to 2007 and so on every 4 years. this code may change or may not change. i wanted to get all the codes to a same year . so i have all the data to get the codes in to a base year code which is 1992. this is the code that im using :
clear all
glo ruta "C:\Users\User\Desktop\Tesis 2019\HS2002"
use "$ruta\\Exportaciones 10 dígitos.dta"
rename Año year
drop if year>2015
drop flujo_comercial ver_par fob flete seguro peso_bruto peso_neto
*aqui sumamos la cantidad d elos mismos productos por año y por pais
collapse (sum) US millón_US , by(Tipo Sector codigo_partida year País Usar_descripción codigo_pais)
*********************************************
*Nos quedamos solo con los paises a trabajar(seria ideal que fueran los mismos que dots)
*********************************************
****************************
*Convertion 2017 to 2012
****************************
rename codigo codigo2017
merge m:m codigo2017 using "$ruta\\correlacionTeorica2012-2017.dta", keepusing(codigo2012)
drop if _merge==2
replace codigo2012= codigo2017 if codigo2012==""
*duplicates drop
rename _merge con2017a2012
****************************
* 2012 to 2007
****************************
merge m:m codigo2012 using "$ruta\\correlacionTeorica2007-2012.dta", keepusing(codigo2007)
drop if _merge==2
replace codigo2007= codigo2012 if codigo2007==""
rename _merge con2012a2007
********************************
* 2007 to 2002 ( HERE IS THE PROBLEM)
********************************
merge m:m codigo2007 using "$ruta\\correlacionTeorica2002-2007.dta", keepusing(codigo2002)
drop if _merge==2
replace codigo2002= codigo2007 if codigo2002==""
rename _merge con2007a2002
Everything is ok until i try to go to 2007 to 2002, it runs but every time gives a different result.
0 Response to Runing the same merge m:m and getting different results
Post a Comment