Hello,
I'm encountering issues with my Stata code. I am trying to establish a loop to compute the Gini for each country and each year. So far, here's my code:
use gini, clear
gen GINIhearng=.
gen sumhearng=.
gen addedhearng=.
gen LorenzCurvehearng=.
gen Bhearng=.
gen Ahearng=.
levelsof cnt2y , local(clist) clean
local nc : word count `clist'
forvalues i=1/`nc' {
local j: word `i' of `clist'
dis `j'
forvalues `j' of varlist cnt2y {
bysort ehearng cnt2y :replace sumhearng = sum(ehearng)
replace addedhearng = sum(ehearng)
replace LorenzCurvehearng = addedhearng/sumhearng
replace Bhearng = sum(LorenzCurvehearng)
replace Ahearng = 5000 - Bhearng
replace GINIhearng = Ahearng/(Ahearng+Bhearng)
}
}
Has anyone any ideas of why the error Stata is giving me is that it's not finding AT2004 which is my first country year code?
I'm encountering issues with my Stata code. I am trying to establish a loop to compute the Gini for each country and each year. So far, here's my code:
use gini, clear
gen GINIhearng=.
gen sumhearng=.
gen addedhearng=.
gen LorenzCurvehearng=.
gen Bhearng=.
gen Ahearng=.
levelsof cnt2y , local(clist) clean
local nc : word count `clist'
forvalues i=1/`nc' {
local j: word `i' of `clist'
dis `j'
forvalues `j' of varlist cnt2y {
bysort ehearng cnt2y :replace sumhearng = sum(ehearng)
replace addedhearng = sum(ehearng)
replace LorenzCurvehearng = addedhearng/sumhearng
replace Bhearng = sum(LorenzCurvehearng)
replace Ahearng = 5000 - Bhearng
replace GINIhearng = Ahearng/(Ahearng+Bhearng)
}
}
Has anyone any ideas of why the error Stata is giving me is that it's not finding AT2004 which is my first country year code?
Comment