My question concerns the following.
I have clustered my data by firm-factory relationship.
Meaning that for each firm-factory cluster I have a unique identifier.
Based on these groups, I want to categorise using an event date.
If within one group (multiple observations over time) there is at least 1 observation before and 1 observation after the event date (01/01/2012).
The categorical value takes x (1).
If within one group (multiple observations over time) there are only observations before or after the event.
The categorical value takes y or z (2 prior, 3 post).
So for example; from the group below the categorical or dummy variable would take 2 (prior) for groupID 125; 1 (prior and post) for groupID 126; and 3 (post) for 128.
I tried to fix it by creating a dummy which takes into account all observations by group. But maybe I am on the wrong track.
Date | groupID |
3/22/2000 | 126 |
10/29/2008 | 126 |
6/16/2009 | 126 |
4/16/2010 | 127 |
12/8/2010 | 127 |
12/7/2012 | 127 |
12/17/2013 | 127 |
12/17/2013 | 128 |
12/20/2017 | 128 |
12/20/2017 | 128 |
3/22/2020 | 128 |
Greetings,
Chiel
0 Response to Categorical values conditional on a date (by group)
Post a Comment