Hello everybody,
I am having the following problem: I want to create a variable that equals the Gini coefficient for the first observation for each country where its Gini coefficient is included in the dataset. So if the first observation for countryxxxx to include the Gini was in 1985 and its Gini that year was 35, every observation for countryxxxx would equal 35 for the new variable. Can you let me know how to do this? My best attempt to so far is the following:
gen gini2 = gini if period == 1
replace gini2=gini2[_n-1] if gini2==.
But it doesn’t work because often the first time the Gini coefficient is recorded for a country it’s not for the first observation for that country. For example countryxxxx has data starting in 1960 but not until many years later did they start recording their Gini.
Any guidance would be greatly appreciated! Thanks
I am having the following problem: I want to create a variable that equals the Gini coefficient for the first observation for each country where its Gini coefficient is included in the dataset. So if the first observation for countryxxxx to include the Gini was in 1985 and its Gini that year was 35, every observation for countryxxxx would equal 35 for the new variable. Can you let me know how to do this? My best attempt to so far is the following:
gen gini2 = gini if period == 1
replace gini2=gini2[_n-1] if gini2==.
But it doesn’t work because often the first time the Gini coefficient is recorded for a country it’s not for the first observation for that country. For example countryxxxx has data starting in 1960 but not until many years later did they start recording their Gini.
Any guidance would be greatly appreciated! Thanks
Comment