Hello everyone,
I am trying to merge two datasets containing observations on firms. Each dataset contains observations on firms across multiple years. The problem is that these datasets come from different databases and the ID from one dataset changes over time. For example: for a company, the ID (which is a code) is EP407011 from 2000 to 2007 and EPB1L2YG after 2007. In the second dataset, the ID is always EPB1L2YG.
Is there a way to merge changing the ID if there is a match at least in one year, using the ID for which there is a match for all years? So in our previous case: if there is a match after 2007 stata will need to change EP407011 to EPB1L2YG from 2000 to 2007.
I don't know if it could be easier but I don't strictly need the merge but only to attach a variable contained in the second dataset to the first. So alternatively, extend this variable (which is another identification code, thus a constant) from the year with a match to the year without a match.
I have no idea where to start to write such a code, and I would like to not lose all matches before 2007 (in the example).
Thank you a lot for your help,
Kind regards,
Gino
Related Posts with Merging with changing ID over time
Measuring duration between age 13 and 19Hi people, Supposed i want to measure marriage timing among pregnant and non pregnant adolescents (a…
Problems with panel dataI am new to stata and I trying to run a regression to understand demographic roles in unemployment, …
How to Keep Duplicated Variables based on the Value of another ColumnHello all! I am working on cleaning up a dataset, and I do not know how to do so. Here are some of …
Query about interaction terms in fixed effects panel dataHi, I have a question about fixed effects panel data interaction terms: Here is my code, xtreg D…
Create a variable to indicate overlappingHello all, I have the dataset as follows. In each observation I have carrier, time(yq), and market(…
Subscribe to:
Post Comments (Atom)
0 Response to Merging with changing ID over time
Post a Comment