Hello all,
I have a dataset that has an ID indicator, a year and an X variable. The data looks like so:
For some units, "A" occurs first chronologically and for others, "B" occurs first chronologically. I want to generate a binary variable by ID that will be 1 if A occurs first chronologically and 0 if B occurs first. I'm sure this is a bysort: egen operation but I'm having a hard time wrapping my head around how to accomplish this.value
Thank you very much in advance!
I have a dataset that has an ID indicator, a year and an X variable. The data looks like so:
ID | Year | X1 |
1 | 2005 | A |
1 | 2011 | B |
2 | 2006 | B |
2 | 2007 | A |
3 | 2003 | A |
3 | 2012 | B |
4 | 2001 | B |
4 | 2003 | A |
5 | 2005 | B |
5 | 2009 | A |
Thank you very much in advance!
Comment