Hi,
I have 2 datasets that needs to be matched/merged. Basically, the two variables I need matched are company codes (coded as GVKEY) and fiscal year.
I.e data set nr 1 is smaller, and I only want the observations that is in data set nr 1. Data set nr 2 I want additional variables, but only for the observations in data set 1 (called Links):
GVKEY FYEAR CUST_GVKEY ..variable.. ..variable... ...variable...
1004 1991 #
1004 1992 #
1004 1993
1009 1991
1009 1992
2023 1993
2023 1994
Data set nr 2(Called Fundamentals):
GVKEY FYEAR EBIT EBITDA ...variable... ...variable...
1002 1991 # #
1002 1992 # #
1002 1993
1004 1991
1004 1992
1004 1993
1009 1991
1009 1992
2023 1993
2023 1994
3432 1991
3432 1992
So I basically want the information contained in data set 2 in data set 1, but only for the specific companies listed in data set 1. I.e say that data set 1 contains only 40 000 firms (individual GVKEYS) and data set 2 has 200 000 different GVKEYS, I only want the information on the 40 000 firms.
So what i did is the following:
use Links.dta
*Once I have the master file open I type:
merge 1:1 GVKEY FYEAR using Fundamentals
I then get an error saying: variables gvkey fyear do not uniquely identify observations in the master data
r(459);
Is it because I have the the same GVKEY numbers stated on several lines?
Can someone help? I am going crazy!
I have 2 datasets that needs to be matched/merged. Basically, the two variables I need matched are company codes (coded as GVKEY) and fiscal year.
I.e data set nr 1 is smaller, and I only want the observations that is in data set nr 1. Data set nr 2 I want additional variables, but only for the observations in data set 1 (called Links):
GVKEY FYEAR CUST_GVKEY ..variable.. ..variable... ...variable...
1004 1991 #
1004 1992 #
1004 1993
1009 1991
1009 1992
2023 1993
2023 1994
Data set nr 2(Called Fundamentals):
GVKEY FYEAR EBIT EBITDA ...variable... ...variable...
1002 1991 # #
1002 1992 # #
1002 1993
1004 1991
1004 1992
1004 1993
1009 1991
1009 1992
2023 1993
2023 1994
3432 1991
3432 1992
So I basically want the information contained in data set 2 in data set 1, but only for the specific companies listed in data set 1. I.e say that data set 1 contains only 40 000 firms (individual GVKEYS) and data set 2 has 200 000 different GVKEYS, I only want the information on the 40 000 firms.
So what i did is the following:
use Links.dta
*Once I have the master file open I type:
merge 1:1 GVKEY FYEAR using Fundamentals
I then get an error saying: variables gvkey fyear do not uniquely identify observations in the master data
r(459);
Is it because I have the the same GVKEY numbers stated on several lines?
Can someone help? I am going crazy!
Comment