Dear all,
I use stata 13. I need do a merge between two datasets with common variables tsymbol cusip fyear. My objective is to replace missing values of cusip in the master(dataone) with the non-missing cusip in the using data (datatwo).
~~~~~~~~~~~~
My code is:
Use dataone
Merge 1:1 tsymbol fyear using datatwo, update replace
~~~~~~~~~~~~
One issue: Tsymbol datatype is str8 in the master(dataone) and str5 in the using data (datatwo).
Question:
~~~~~~~~~~~~
dataone
Input str8 Tsymbol fyear str9 cusip for_co
~~~~~~~~~~~~
~~~~~~~~~~~~
Datatwo
Input str6 gvkey fyear str5 tysbol str9 cusip
I also attached the data in excel.
thanks in advance,
Rochelle
I use stata 13. I need do a merge between two datasets with common variables tsymbol cusip fyear. My objective is to replace missing values of cusip in the master(dataone) with the non-missing cusip in the using data (datatwo).
~~~~~~~~~~~~
My code is:
Use dataone
Merge 1:1 tsymbol fyear using datatwo, update replace
~~~~~~~~~~~~
One issue: Tsymbol datatype is str8 in the master(dataone) and str5 in the using data (datatwo).
Question:
- Should I change the string length
- Should I revise my code to accomplish my goal?
~~~~~~~~~~~~
dataone
Input str8 Tsymbol fyear str9 cusip for_co
A | 2000 | . | 3 |
A | 2001 | . | 5 |
A | 2002 | . | 7 |
A | 2003 | . | 6 |
A | 2004 | . | 10 |
AA | 2000 | 1381710 | 1 |
AA | 2001 | 1381710 | 1 |
AA | 2004 | 1381710 | 1 |
AAC.OLD | 1995 | . | 1 |
AACC | 2005 | . | 2 |
AACC | 2007 | . | 3 |
~~~~~~~~~~~~
Datatwo
Input str6 gvkey fyear str5 tysbol str9 cusip
126554 | 1999 | A | 00846U101 |
126554 | 2000 | A | 00846U101 |
126554 | 2001 | A | 00846U101 |
126554 | 2002 | A | 00846U101 |
126554 | 2003 | A | 00846U101 |
126554 | 2004 | A | 00846U101 |
126554 | 2005 | A | 00846U101 |
157058 | 2001 | AACC | 04543P100 |
157058 | 2002 | AACC | 04543P100 |
157058 | 2003 | AACC | 04543P100 |
157058 | 2004 | AACC | 04543P100 |
157058 | 2005 | AACC | 04543P100 |
157058 | 2006 | AACC | 04543P100 |
157058 | 2007 | AACC | 04543P100 |
157058 | 2008 | AACC | 04543P100 |
157058 | 2009 | AACC | 04543P100 |
I also attached the data in excel.
thanks in advance,
Rochelle
Comment