Hi everybody,
I have a panel data and I need to create a new variable based on a dummy variable which varies over time.
In particular the new variable should assume a value equal to the sum of 1 that the dummy variable presents up to the considered year.
I'm trying to obtain a database like the following:
Thanks in advance
Giancarlo
I have a panel data and I need to create a new variable based on a dummy variable which varies over time.
In particular the new variable should assume a value equal to the sum of 1 that the dummy variable presents up to the considered year.
I'm trying to obtain a database like the following:
PRODUCT | ORIGIN | YEAR | VARIABLE X | NEW VARIABLE |
A | BG | 1995 | 0 | 0 |
A | BG | 1996 | 1 | 1 |
A | BG | 1997 | 0 | 1 |
A | BG | 1998 | 1 | 2 |
A | BG | 1999 | 1 | 3 |
B | BG | 1995 | 1 | 1 |
B | BG | 1996 | 0 | 1 |
B | BG | 1997 | 1 | 2 |
B | BG | 1998 | 1 | 3 |
B | BG | 1999 | 1 | 4 |
A | MI | 1995 | 0 | 0 |
A | MI | 1996 | 0 | 0 |
A | MI | 1997 | 1 | 1 |
A | MI | 1998 | 0 | 1 |
A | MI | 1999 | 0 | 1 |
Thanks in advance
Giancarlo
Comment