Hi,
I am new to Stata 15 and I need some help.
I have two databases (database_y and database_x). I have 4 variables that are named the same (year, product, code of province origin and code of region origin) in both databases.
In the database_y I have additional information (it gives me the destination of the provinces and regions of origin). So, I just wanted to merge both databases in order to have the source information and to add the destination provinces/regions.
I have tried to make a merge, but I have an answer from Stata: variable year product o_province_code o_region_code does not uniquely identify observations in the master/using data r(459);
I have looked at some examples on the forum and none have solved my problem.
* Database_x
* Example generated by -dataex-. To install: ssc install dataex
clear
input str4 year str2(product o_province_code) byte(o_region_code o_customs_code) double(tm_exports_x vm_exports_x)
"2010" "01" "8" 9 8 .35 696
"2010" "01" "43" 9 11 .8 5000
"2010" "04" "41" 1 11 .168 150
"2010" "05" "31" 15 11 .104 3058.14
"2010" "05" "11" 1 11 .18 1920
"2011" "01" "46" 10 11 .043000000000000004 1450
"2011" "01" "43" 9 11 .2 350
"2011" "01" "41" 1 11 .55 9840
"2011" "05" "31" 15 11 1.437 38284.23
"2012" "01" "11" 1 11 .55 2000
"2012" "03" "15" 12 15 .106 10051.49
"2012" "03" "28" 13 11 .3 3420
"2012" "04" "26" 17 11 .026 156.23
"2012" "04" "19" 8 11 .192 391.8
"2012" "05" "43" 9 11 .794 10875.91
"2012" "05" "25" 9 11 1.239 5940
"2013" "01" "4" 1 4 .45 1800
"2013" "01" "15" 12 11 .5 3700
"2014" "01" "43" 9 11 .171 14726
"2015" "01" "46" 10 11 .6 1000
"2015" "01" "29" 1 11 .8 2200
"2015" "02" "24" 7 11 .121 2150
"2015" "03" "3" 10 3 .99 20195
"2015" "05" "18" 1 46 .8 6840
"2015" "05" "31" 15 8 4.106 7672.18
"2016" "01" "28" 13 11 .036 930
"2016" "01" "15" 12 11 .168 238
"2016" "02" "2" 8 11 .097 2657.05
"2016" "02" "37" 7 11 .12 1029.67
"2016" "03" "29" 1 11 .096 379.2
"2016" "03" "17" 9 11 .977 22867
"2016" "05" "33" 3 11 .216 270
"2016" "05" "28" 13 11 .8 247.98
"2017" "01" "30" 14 11 .6 9000
"2017" "01" "29" 1 11 .825 60
"2017" "02" "37" 7 11 .172 1796.7799999999997
"2017" "02" "24" 7 11 .235 3917.43
"2017" "02" "25" 9 11 .296 3109.67
"2017" "04" "12" 10 11 .003 19.02
"2017" "04" "45" 8 8 .15 405
"2017" "05" "31" 15 8 3.424 14424.9
"2018" "02" "24" 7 11 .102 1794.04
"2018" "02" "25" 9 11 .208 1543.06
"2018" "03" "3" 10 3 .4 5750
"2018" "03" "43" 9 11 .432 915.84
"2018" "03" "18" 1 11 .9 3253.45
"2018" "04" "29" 1 46 .12 660
"2018" "04" "2" 8 11 .213 2814.06
end
*Database y
* Example generated by -dataex-. To install: ssc install dataex
clear
input str4 year str2(product o_province_code) byte o_region_code int d_province_code byte d_region_code long exports_tm_y
"2010" "03" "11" 1 1 9 .
"2010" "03" "35" 5 1 9 148
"2010" "03" "P8" 9 1 9 .
"2010" "03" "46" 10 1 9 12
"2010" "03" "36" 12 1 9 155
"2011" "03" "11" 1 1 9 7
"2011" "03" "29" 1 1 9 .
"2011" "03" "35" 5 1 9 97
"2011" "03" "P8" 9 1 9 .
"2011" "03" "36" 12 1 9 57
"2014" "08" "11" 1 141 6 .
"2014" "08" "P8" 9 141 6 1
"2016" "08" "11" 1 141 6 .
"2010" "08" "35" 5 321 11 18
"2010" "08" "P4" 1 381 2 195
"2011" "08" "P4" 1 381 2 116
"2012" "10" "46" 10 1 9 22
"2013" "10" "11" 1 1 9 .
"2013" "10" "35" 5 1 9 .
"2013" "10" "P8" 9 1 9 .
"2013" "10" "46" 10 1 9 .
"2014" "10" "11" 1 1 9 .
"2015" "10" "11" 1 1 9 .
"2010" "25" "P3" 10 1 9 35028
"2010" "25" "46" 10 1 9 572
"2010" "25" "36" 12 1 9 69
"2010" "25" "48" 16 1 9 46
"2011" "25" "11" 1 1 9 .
"2011" "25" "35" 5 1 9 .
"2011" "25" "P8" 9 1 9 48
"2011" "25" "46" 10 1 9 164
end
I will be grateful for any help you can provide
Related Posts with New to stata. Need some hepl
calculate averages of groups of observations separated by groups of missing observationsHi everybody, I have panel data with a few variables that have a somewhat random pattern. I need to…
Mark all observations that has one variable in commonHello, I'm quite new to stata. I have searched in this forum, but can not find the answer I need, th…
Calculating difference between observations in a panel with missing valuesHello! I am working with online auction data (see -dataex- below), where id is the listing identifi…
Converting R date into STATA dateHi, I am trying to convert R dates into STATA dates but unable to do so. For example, the R date i…
poisson regression with instrumental variables and high dimensional fixed effectsI have a poisson regression model with large number of fixed effects and an endogenous independent v…
Subscribe to:
Post Comments (Atom)
0 Response to New to stata. Need some hepl
Post a Comment