I have two questions for you.
I have a panel in which I have date, ID, company and outcome.
I would generate a dummy if in 30 days id and company are repeated.
I did something like this but is not really working to capture all events.
Code:
bys company (date): g repetition=(date[_n]-date[_n-1]<30 & company[_n]==company[_n-1] & ID[_n]==ID[_n-1])
For instance, I want drop line 2 and substitute outcome in line 1 with the mean between 10 and 20.
DATE | ID | COMPANY | OUTCOME |
01/01/2020 | 1 | Y | 10 |
02/01/2020 | 1 | Y | 20 |
03/04/2021 | 1 | Z | 45 |
04/05/2022 | 2 | X | 50 |
Thanks
0 Response to sorting and creation of variables
Post a Comment