My data is in the following format:
clear all
input year ID var1 var2
2000 1 100 .
2001 1 200 0.2
2002 1 300 0.3
2000 2 500 .
2001 2 300 0.4
2002 2 400 0.1
end
I would like to create an interaction variable between var1 and var2 where var1 always takes the value of the first year where I have data (in this case year 2000 as the base year).
| year | ID | var1 | var2 | var1xvar2 |
|---|---|---|---|---|
| 2000 | 1 | 100 | . | . |
| 2001 | 1 | 200 | 0.2 | 20 |
| 2002 | 1 | 300 | 0.3 | 30 |
| 2000 | 2 | 500 | . | . |
| 2001 | 2 | 300 | 0.4 | 200 |
| 2002 | 2 | 400 | 0.1 | 50 |
How can I achieve this?