I am having a simple problem with merging interest rate data with a country identifier variable. I am using the following basic code:
merge m:1 country using "`root_folder'/ID.dta"
The master dataset is the interest rate data and the using data is simply a dataset linking each country to a unique number.
Here is a Data example for my interest rate data:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float date str12 country float Tbonds
-161438 "Netherlands " .2
-161073 "Netherlands " .1805
-160708 "Netherlands " .1717
-160342 "Netherlands " .1544
-159977 "Netherlands " .1822
-159612 "Netherlands " .1978
-159247 "Netherlands " .1458
-158881 "Netherlands " .1225
-158516 "Netherlands " .1217
-158151 "Netherlands " .1276
-157786 "Netherlands " .167
-157420 "Netherlands " .1902
-157055 "Netherlands " .1948
-156690 "Netherlands " .1869
-156325 "Netherlands " .1748
-155959 "Netherlands " .1594
-155229 "Netherlands " .1338
-154864 "Netherlands " .1325
-154498 "Netherlands " .1672
-154133 "Netherlands " .1525
-153768 "Netherlands " .1263
-153403 "Netherlands " .1488
-153037 "Netherlands " .156
-152672 "Netherlands " .1188
-152307 "Netherlands " .1188
-151942 "Netherlands " .12
-151576 "Netherlands " .15
-151211 "Netherlands " .11
-150846 "Netherlands " .1156
-150481 "Netherlands " .11
-150115 "Netherlands " .1
-149750 "Netherlands " .0975
-148654 "Netherlands " .08333
-145732 "Netherlands " .0625
-140619 "Netherlands " .2
-139888 "Netherlands " .08333
-131122 "Netherlands " .085
-130757 "Netherlands " .085
-130392 "Netherlands " .085
-130027 "Netherlands " .085
-129661 "Netherlands " .085
-129296 "Netherlands " .085
-128931 "Netherlands " .071427
-128566 "Netherlands " .071427
-128200 "Netherlands " .071427
-127835 "Netherlands " .071427
-127470 "Netherlands " .071427
-127105 "Netherlands " .071427
-126739 "Netherlands " .071427
-126374 "Netherlands " .071427
-126009 "Netherlands " .071427
-125644 "Netherlands " .071427
-125278 "Netherlands " .071427
-124913 "Netherlands " .071427
-124548 "Netherlands " .071427
-124183 "Netherlands " .071427
-123817 "Netherlands " .061666
-123452 "Netherlands " .061666
-123087 "Netherlands " .061666
-122722 "Netherlands " .061666
-122356 "Netherlands " .061666
-121991 "Netherlands " .061666
-121626 "Netherlands " .061666
-121261 "Netherlands " .061666
-120895 "Netherlands " .061666
-120530 "Netherlands " .061666
-120165 "Netherlands " .061666
-119800 "Netherlands " .061666
-119434 "Netherlands " .061666
-119069 "Netherlands " .061666
-118704 "Netherlands " .061666
-118339 "Netherlands " .061666
-117973 "Netherlands " .061666
-117608 "Netherlands " .061666
-117243 "Netherlands " .061666
-116878 "Netherlands " .061666
-116512 "Netherlands " .05
-116147 "Netherlands " .05
-115782 "Netherlands " .05
-115417 "Netherlands " .05
-115051 "Netherlands " .05
-114686 "Netherlands " .05
-114321 "Netherlands " .05
-113956 "Netherlands " .05
-113590 "Netherlands " .05
-113225 "Netherlands " .05
-112860 "Netherlands " .05
-112495 "Netherlands " .05
-112129 "Netherlands " .05
-111764 "Netherlands " .05
-111399 "Netherlands " .04
-111034 "Netherlands " .04
-110668 "Netherlands " .04
-110303 "Netherlands " .04
-109938 "Netherlands " .04
-109573 "Netherlands " .04
-109207 "Netherlands " .04
-108842 "Netherlands " .04
-108477 "Netherlands " .04
-108112 "Netherlands " .04
end
format %td date
Here is the data ex for my id variable.
copy starting from the next line ------ ----------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str11 country byte ID "Argentina" 1 "Australia" 2 "Austria" 3 "Belgium" 4 "Brazil" 5 "Bulgaria" 6 "Canada" 7 "Chile" 8 "China" 9 "Colombia" 10 "Croatia" 11 "Czech" 12 "Denmark" 13 "Ecuador" 14 "Egypt" 15 "Euro" 16 "France" 17 "Germany" 18 "Greece" 19 "HK" 20 "Hungary" 21 "Iceland" 22 "India" 23 "Indonesia" 24 "Ireland" 25 "Israel" 26 "Japan" 27 "Kuwait" 28 "Latvia" 29 "Lithuania" 30 "Luxembourg" 31 "Mexico" 32 "Netherlands" 33 "Norway" 34 "NZ" 35 "Peru" 36 "Philippines" 37 "Poland" 38 "Portugal" 39 "Russia" 40 "SA" 41 "Saudi" 42 "Singapore" 43 "Spain" 44 "Sweden" 45 "Switzerland" 46 "Taiwan" 47 "Thailand" 48 "Turkey" 49 "UK" 50 "Vietnam" 51 end
Listed 51 out of 51 observations
For some reason running this simple merging code doesn't lead to a perfect match for all my observations. I have no idea why.
0 Response to Simple Merging Issue with ID variable
Post a Comment