Hello,
I am having trouble merging two datasets for my thesis. To reduce clutter, I have only included 4 different variables. 'gvkey' and 'fyear' are the identifiers for these datasets and 'debt' and 'PrincipalAmtDbtOutstanding' are used to check if the sets are merged correctly (they are roughly the same).
I would like the datasets to merge on gvkey and fyear. If a certain gvkey is missing observations in fyear I would like STATA to create a missing value for either 'debt' or 'PrincipalAmtDbtOutstanding'.
As can be seen from the datasets below, there are more observations for gvkey and fyear in the first dataset than in the second dataset.
I have tried a 1:1 merge, a 1:m merge and a m:1 merge, but they all give the same error code: "variables gvkey fyear do not uniquely identify observations in the master data" r(459).
Thanks in advance!
Kind regards,
Maks van Noort
gvkey fyear debt
001166 2014 0
001166 2015 0
001166 2016 0
001166 2017 0
001166 2018 0
008546 2014 4104
008546 2015 5760
008546 2016 5606
008546 2017 3697
008546 2018 3927
010846 2014 12372
010846 2015 14519
010846 2016 16410
010846 2017 24009
010846 2018 24483
013145 2014 6617
013145 2015 8630
013145 2016 8515
013145 2017 7331
013145 2018 7509
013556 2014 1576
013556 2015 1536.3
013556 2016 1545.1
013556 2017 1660.8
013556 2018 2729.7
013683 2014 56150
013683 2015 56735
013683 2016 56842
013683 2017 52594
013683 2018 52304
013932 2014 65.149
013932 2015 62.781
013932 2016 1875.368
013932 2017 1896.965
013932 2018 1919.5
and
gvkey fyear PrincipalAmtDbtOutstanding
001166 2016 0
001166 2017 0
008546 2014 4135
008546 2015 5796
008546 2016 5637
008546 2017
008546 2018
010846 2014
010846 2014
010846 2016
010846 2017
010846 2018
013145 2014 6617
013145 2015
013145 2016 8515
013145 2017 7331
013556 2014 1559.200000000000045
013556 2015
013556 2016
013556 2017 1660.799999999999955
013683 2014 56769
013683 2015 56734
013683 2016
013683 2017 52707
013932 2014
013932 2014
013932 2015
013932 2016 1939.70900000000006
0 Response to I need help on merging two datasets.
Post a Comment