Hello!
I need to merge two panel datasets into one. For this, I need to conduct two steps:
1. Create for each ISIN year variables from 1997-2021 except those that are already present in the dataset.
So eventually, I want to transform this:
...into this:
2. I need to merge the following (patchy) dataset onto the above dataset based on the ISINs and years:
Eventually, this is supposed to be the outcome:
Does anybody know how I could code this in STATA?
Thank you very much in advance!
I need to merge two panel datasets into one. For this, I need to conduct two steps:
1. Create for each ISIN year variables from 1997-2021 except those that are already present in the dataset.
So eventually, I want to transform this:
ISIN | year |
isin1 | 1998 |
isin1 | 2012 |
isin1 | 2013 |
isin2 | 2007 |
isin2 | 2008 |
isin2 | 2015 |
ISIN | year |
isin1 | 1997 |
isin1 | 1998 |
... | ... |
isin1 | 2021 |
isin2 | 1997 |
isin2 | 1998 |
... | ... |
isin2 | 2021 |
ISIN | year | P/E ratio |
isin1 | 1998 | 5 |
isin1 | 2015 | 2 |
isin2 | 1997 | 4.5 |
isin2 | 2017 | 3 |
Eventually, this is supposed to be the outcome:
ISIN | year | P/E ratio |
isin1 | 1997 | NA |
isin1 | 1998 | 5 |
... | ... | |
isin1 | 2020 | NA |
isin2 | 1997 | 4.5 |
isin2 | 1998 | NA |
... | ... | |
isin2 | 2021 | NA |
Does anybody know how I could code this in STATA?
Thank you very much in advance!
Comment