Hello all. I have a long-format database that looks like this:
id |
wave |
var1 |
var2 |
1 |
1 |
85 |
. |
1 |
2 |
. |
. |
1 |
3 |
87 |
. |
1 |
4 |
. |
5 |
2 |
1 |
. |
. |
2 |
2 |
92 |
. |
2 |
3 |
76 |
. |
2 |
4 |
. |
8 |
I need a variable that is generated using
var1 and
var2 (let's call it
var3). Now, I would only keep observations from wave 4 because that's where I have the measurement for
var2, but that would be useless because I wouldn't have any measurement for
var1 in wave 4.
So my question is, is there a way to generate a new variable (let's say
var1_new) that is equal to the most recent measurement of
var1 for each id? So that I would have something like the following:
id |
wave |
var1 |
var2 |
var1_new |
1 |
4 |
. |
5 |
87 |
2 |
4 |
. |
8 |
76 |
Any help is appreciated, thank you.
0 Response to Keep only most recent measure with panel data
Post a Comment