Hi,
I need to compute overall theil index, within and between decomposition and inequality for subgroup k, where my subgroup variable is age_class.
I am using ineqdeco and I am able to get the desired results for one country, these are the command I am running:

gen ge1 = . // theil overall index
gen ge1_w = . // within decomposition overall
gen ge1_b = . // btw decomposition overall
gen ge_lev =. // inequality for subgroup k, is calculated as if the subgroup were a separate population
egen subgroup = group( age_class)

keep if country=="AT"

levels subgroup, local(levels)
foreach i in `r(levels)' {
ineqdeco health [w=weight], by (subgroup)
replace ge1 = r(ge1)
replace ge1_w = r(within_ge1)
replace ge1_b = r(between_ge1)

replace ge_lev = r(ge1_`i') if subgroup==`i'
}

My point is that I would like to run the same routine for several countries at the same time but I am not interested in inequality (both within or between) across countries but only across age for each country.
I tried to loop with foreach country but I got the same ge1, ge1_w, ge1_b for all countries meaning that the routine is computing inequality across countries.

Any suggestions would be very much appreciated!

regards
dalila