Dear Statalist,
I have the following panel data list and I need to generate Var 2 based on
Var 1 for IDs that increase their value from 0 in the previous year.
Var 2 takes value 1 only if an ID increases its value from zero previous year to 1 ( or a higher positive number) in the current year and zero otherwise.
Appreciate your help.
I have the following panel data list and I need to generate Var 2 based on
Var 1 for IDs that increase their value from 0 in the previous year.
Var 2 takes value 1 only if an ID increases its value from zero previous year to 1 ( or a higher positive number) in the current year and zero otherwise.
| Year | ID | Var1 | Var2 |
| 1990 | 1 | 0 | 0 |
| 1990 | 2 | 0 | 0 |
| 1990 | 3 | 2 | 0 |
| 1990 | 4 | 2 | 0 |
| 1990 | 5 | 1 | 0 |
| 1990 | 6 | . | 0 |
| 1991 | 1 | 1 | 1 |
| 1991 | 2 | 0 | 0 |
| 1991 | 3 | 2 | 0 |
| 1991 | 4 | 3 | 0 |
| 1991 | 5 | 1 | 0 |
| 1991 | 6 | 0 | 0 |
| 1992 | 1 | 2 | 0 |
| 1992 | 2 | 2 | 1 |
| 1992 | 3 | 4 | 0 |
| 1992 | 4 | 2 | 0 |
| 1992 | 5 | 1 | 0 |
| 1992 | 6 | 1 | 1 |

Comment