Hi,
I would like to merge two datasets (see below).
Dataset 1 consists of pairs
Dataset 2 doesn't have pairs but covers a longer time period.
I tried with merge but the new observations in dataset 2 (ie. those before 2010 and after 2015q2) didn't get matched with the ID2 variable. I basically would like each pair to cover the longer time period (as in dataset 2).
Any tips would be appreciated.
I would like to merge two datasets (see below).
Dataset 1 consists of pairs
Dataset 2 doesn't have pairs but covers a longer time period.
I tried with merge but the new observations in dataset 2 (ie. those before 2010 and after 2015q2) didn't get matched with the ID2 variable. I basically would like each pair to cover the longer time period (as in dataset 2).
Any tips would be appreciated.
Dataset 1 | Dataset 2 | What the merge should look like | |||||||||||||||||||
ID1 | ID2 | TIME | Y1 | Y2 | Y3 | ID1 | TIME | Z1 | Z2 | Z3 | ID1 | ID2 | TIME | Y1 | Y2 | Y3 | Z1 | Z2 | Z3 | ||
A1 | B | 2010Q1 | A1 | 1999Q4 | A1 | B | 1999Q4 | ||||||||||||||
A1 | B | 2010Q2 | A1 | 2000Q1 | A1 | B | 2000Q1 | ||||||||||||||
A1 | B | 2010Q3 | A1 | 2000Q2 | A1 | B | 2000Q2 | ||||||||||||||
A1 | B | 2010Q4 | A1 | .. | A1 | B | .. | ||||||||||||||
A1 | B | … | A1 | .. | A1 | B | .. | ||||||||||||||
A1 | B | .. | A1 | 2016Q2 | A1 | B | 2016Q2 | ||||||||||||||
A1 | B | 2015Q2 | A2 | 1999Q4 | A1 | C | 1999Q4 | ||||||||||||||
A1 | C | 2010Q1 | A2 | 2000Q1 | A1 | C | 2000Q1 | ||||||||||||||
A1 | C | 2010Q2 | A2 | 2000Q2 | A1 | C | 2000Q2 | ||||||||||||||
A1 | C | 2010Q3 | A2 | .. | A1 | C | .. | ||||||||||||||
A1 | C | 2010Q4 | A2 | .. | A1 | C | .. | ||||||||||||||
A1 | C | … | A2 | 2016Q2 | A1 | C | 2016Q2 | ||||||||||||||
A1 | C | .. | … | A2 | B | 1999Q4 | |||||||||||||||
A1 | C | 2015Q2 | A2 | B | 2000Q1 | ||||||||||||||||
A2 | B | 2010Q1 | A2 | B | 2000Q2 | ||||||||||||||||
A2 | B | 2010Q2 | A2 | B | .. | ||||||||||||||||
A2 | B | 2010Q3 | A2 | B | .. | ||||||||||||||||
A2 | B | 2010Q4 | A2 | B | 2016Q2 | ||||||||||||||||
A2 | B | … | A2 | C | 1999Q4 | ||||||||||||||||
A2 | B | .. | A2 | C | 2000Q1 | ||||||||||||||||
A2 | B | 2015Q2 | A2 | C | 2000Q2 | ||||||||||||||||
A2 | C | 2010Q1 | A2 | C | .. | ||||||||||||||||
A2 | C | 2010Q2 | A2 | C | .. | ||||||||||||||||
A2 | C | 2010Q3 | A2 | C | 2016Q2 | ||||||||||||||||
A2 | C | 2010Q4 | .. | ||||||||||||||||||
A2 | C | … | .. | ||||||||||||||||||
A2 | C | .. | |||||||||||||||||||
A2 | C | 2015Q2 | |||||||||||||||||||
.. | |||||||||||||||||||||
.. |
Comment