Hello everyone,
I'm trying to create lead and lag variables in an (unbalanced) panel data. What I want to do is quite straightforward, however, I can't seem to find the solution in Stata.
My unbalanced panel data is the following
I have the variable Revenue and I would like to have Revenue x years (let's say 2 years) after a certain event (let's say when the company acquires its own facilities).
For the firm #4 for example, which experienced the event in 2014, I want the Revenue 2 years after that (in 2016) which is 178057.
My concern is that I don't know how to create the lead and the lags since my time variable of reference is the EventYear while my panel data is set up on the Year variable (not the EventYear)
I am actually looking for an equivalent to the vlookup command in Excel - but that would also work with missing values in Stata.
Would you have any advice on how to go about this?
Thank you so much in advance!
Jeanne
I am using Stata 16.1 for Mac
I'm trying to create lead and lag variables in an (unbalanced) panel data. What I want to do is quite straightforward, however, I can't seem to find the solution in Stata.
My unbalanced panel data is the following
Code:
xtdes
No: 1, 4, ..., 1109 n = 720
Year: 2013, 2014, ..., 2019 T = 7
Delta(Year) = 1 unit
Span(Year) = 7 periods
(No*Year uniquely identifies each observation)
Distribution of T_i: min 5% 25% 50% 75% 95% max
1 1 2 3 6 7 7
Freq. Percent Cum. | Pattern
---------------------------+---------
163 22.64 22.64 | ......1
146 20.28 42.92 | 1111111
110 15.28 58.19 | .....11
95 13.19 71.39 | ....111
79 10.97 82.36 | ...1111
67 9.31 91.67 | ..11111
60 8.33 100.00 | .111111
---------------------------+---------
720 100.00 | XXXXXXX
For the firm #4 for example, which experienced the event in 2014, I want the Revenue 2 years after that (in 2016) which is 178057.
Code:
list No Year EventYear Revenue in f/10
+---------------------------------+
| No Year EventYear Revenue |
|---------------------------------|
1. | 1 2015 2015 . |
2. | 1 2016 2015 . |
3. | 1 2017 2015 . |
4. | 1 2018 2015 . |
5. | 1 2019 2015 144851 |
|---------------------------------|
6. | 4 2014 2014 213553 |
7. | 4 2015 2014 . |
8. | 4 2016 2014 178057 |
9. | 4 2017 2014 177342 |
10. | 4 2018 2014 . |
+---------------------------------+
Code:
xtset No Year
panel variable: No (unbalanced)
time variable: Year, 2013 to 2019
delta: 1 unit
Would you have any advice on how to go about this?
Thank you so much in advance!
Jeanne
I am using Stata 16.1 for Mac

Comment