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.
Related Posts with Runing the same merge m:m and getting different results
Bar charts: Percent on y-axis, absolute count over each bar?Hi, I'm making a bunch of barcharts, some using graph, some using catplot, like this: Code: grap…
can we order the variables after -egen- ? Code: egen progsvness=rowmean(techAdvt prodAdvt) order progsvness,a(prodAdvt) the cod…
Log transform a variableIf we try to log transform a variable in STATA, why does the result(logX value) obtained differ from…
GMM with multi-level moment conditonsHi all, I want to do a two-step GMM estimation with multi-level moment conditons (the objective fun…
I am shocked that Stata may not understand variable names literallyI have this simplest dataset. var new 0 1 Then I type tab va then it should throw me an error sa…
Subscribe to:
Post Comments (Atom)
0 Response to Runing the same merge m:m and getting different results
Post a Comment