My dataset contains a year, ID, and binary value variable.
ID | Year | Value |
---|---|---|
1 | 2000 | 0 |
1 | 2001 | 0 |
1 | 2002 | 1 |
1 | 2003 | 1 |
1 | 2004 | 1 |
1 | 2005 | 1 |
Using Stata, I would like to create a new variable "YearValue" that takes the value of the variable "Year" when the variable value first turned 1.
ID | Year | Value | YearValue |
---|---|---|---|
1 | 2000 | 0 | 2002 |
1 | 2001 | 0 | 2002 |
1 | 2002 | 1 | 2002 |
1 | 2003 | 1 | 2002 |
1 | 2004 | 1 | 2002 |
1 | 2005 | 1 | 2002 |
Thank you for your help!