Dear all,
I have panel covering the period 1970-2010 with country-year being the unit of analysis. The data looks something like this:
country |
year |
X |
A |
1970 |
12 |
A |
1971 |
9 |
B |
1970 |
8 |
B |
1971 |
11 |
B |
1972 |
13 |
B |
1973 |
4 |
C |
1970 |
5 |
C |
1971 |
3 |
C |
1972 |
8 |
I would like to generate a variable
X1 in Stata that would take the first value of X( that is in 1970!) for the whole period. So for example, the X1 for country B should be "8" for all years. To illustrate this:
country |
year |
X |
X1 |
A |
1970 |
12 |
12 |
A |
1971 |
9 |
12 |
B |
1970 |
8 |
8 |
B |
1971 |
11 |
8 |
B |
1972 |
13 |
8 |
B |
1973 |
4 |
8 |
C |
1970 |
5 |
5 |
C |
1971 |
5 |
5 |
C |
1972 |
5 |
5 |
I've tried different things with "generate X1= if" what I can't come up how to solve this. Anyone here who can help me with this?
0 Response to What is the Stata command to generate a variable that would take the initial value of the other variable?
Post a Comment