Dear All,

I'm using Stata 16 and I'm trying to decompose my concentration index using the following independent variables: equivalised_income, race, gender, geo educ_m (mother education), empl_m (mother employment), wt_m (mother weight). I get an error message saying that my varlist is not allowed, with code r(101). Obese is a binary variable

My commands are as follows

Code:
conindex obese [aweight=wt], rankvar(wquintile) wagstaff bounded limits (1 2)
I get the results for conindex.

Global X is as follows;

Code:
global X quintile feedingscheme race gender geo educ_m empl_m  wt_m
qui regr obese $X [pw=wt] 
sum obese [aw=wt]
sca m_obese=r(mean)
No problem here

Then when i try the below I get the error message that says varlist not allowed
Code:
foreach x of global X { 
qui {  
sca b_`x’ = _b[`x’]    
corr rank `x’ [pw=wt], c  
sca cov_`x’ = r(cov_12)      
sum `x’ [aw=wt] 
sca elas_`x’ = (b_`x’*r(mean))/m_obese  
sca CI_`x’ = 2*cov_`x’/r(mean)   
sca con_`x’ = elas_`x’*CI_`x’ 
sca prcnt_`x’ = con_`x’/CI   
} 
di “`x’ elasticity:”, elas_`x’ 
di “`x’ concentration index:”, CI_`x’ 
di “`x’ contribution:”, con_`x’ 
di “`x’ percentage contribution:”, prcnt_`x’
}
Results:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(equivalized_income feedingscheme) byte(race gender geo) float(empl_m educ_m wt_m)
1035.9819 . 2 2 1 . . .
254.44856 . 2 1 1 . . .
254.44856 . 2 2 1 . . .
254.44856 2 2 2 1 1 1 2
254.44856 2 2 2 1 1 1 2
 546.3166 . 2 1 1 . . .
 546.3166 . 2 2 1 . . .
 546.3166 . 2 1 1 . . .
 202.3135 . 2 2 1 . . .
 202.3135 2 2 1 1 1 1 2
 933.5438 . 2 2 1 . . .
117.27608 . 2 1 1 . . .
117.27608 . 2 1 1 . . .
 740.8214 . 2 2 1 . . .
 740.8214 . 2 1 1 2 1 3
 740.8214 2 2 2 1 2 1 3
 740.8214 2 2 2 1 2 1 3
547.75574 . 2 2 1 . . .
547.75574 1 2 2 1 2 1 3
547.75574 2 2 1 1 2 1 3
547.75574 2 2 2 1 . . .
547.75574 . 2 1 1 . . .
 940.7536 . 2 1 1 . . .
 940.7536 2 2 2 1 . . .
 940.7536 2 2 1 1 . . .
 940.7536 2 2 2 1 . . .
 940.7536 . 2 2 1 . . .
 940.7536 2 2 2 1 . . .
 965.0203 . 2 1 1 1 1 4
 965.0203 . 2 2 1 . . .
 965.0203 . 2 2 1 . . .
 965.0203 2 2 1 1 2 1 2
 965.0203 2 2 2 1 2 1 2
 965.0203 . 2 2 1 2 1 2
 965.0203 . 2 1 1 2 1 2
126.10336 2 2 1 1 . . .
126.10336 2 2 1 1 . . .
126.10336 . 2 1 1 . . .
126.10336 2 2 1 1 . . .
300.64355 . 2 2 1 . . .
300.64355 . 2 2 1 . . .
300.64355 . 2 2 1 . . .
300.64355 2 2 2 1 1 1 4
300.64355 . 2 1 1 . . .
300.64355 . 2 1 1 . . .
300.64355 2 2 1 1 . . .
300.64355 2 2 1 1 1 1 4
300.64355 2 2 2 1 1 1 2
300.64355 2 2 2 1 1 1 4
300.64355 2 2 1 1 . . .
299.02875 2 2 1 1 . . .
299.02875 1 2 2 1 . . .
299.02875 . 2 1 1 . . .
299.02875 1 2 2 1 . . .
299.02875 2 2 2 1 . . .
299.02875 . 2 2 1 . . .
299.02875 . 2 1 1 . . .
299.02875 2 2 2 1 . . .
299.02875 2 2 1 1 . . .
299.02875 . 2 1 1 . . .
299.02875 . 2 1 1 . . .
299.02875 . 2 2 1 . . .
299.02875 . 2 1 1 . . .
299.02875 . 2 1 1 1 2 2
 420.0078 . 2 2 1 . . .
 420.0078 . 2 1 1 . . .
 420.0078 . 2 2 1 1 1 2
 706.9612 . 2 2 1 . . .
 706.9612 . 2 2 1 1 2 2
 706.9612 2 2 2 1 1 2 2
 706.9612 2 2 1 1 1 2 2
 412.6564 . 2 1 1 1 1 1
 412.6564 . 2 2 1 . . .
 412.6564 . 2 2 1 . . .
 721.2489 2 2 1 1 2 1 4
 721.2489 1 2 2 1 2 1 4
 721.2489 . 2 2 1 2 1 4
 721.2489 . 2 2 1 . . .
 721.2489 2 2 2 1 2 1 4
 721.2489 . 2 1 1 1 3 3
 721.2489 2 2 2 1 2 1 4
 742.3904 . 2 2 1 1 1 4
 742.3904 . 2 2 1 1 1 4
 742.3904 . 2 2 1 . . .
 742.3904 . 2 2 1 1 2 3
 742.3904 2 2 1 1 1 2 3
 742.3904 . 2 2 1 1 2 4
 742.3904 1 2 2 1 1 2 4
 424.4521 . 2 2 1 1 1 4
 424.4521 . 2 1 1 . . .
 424.4521 1 2 2 1 1 1 4
 424.4521 . 2 2 1 . . .
 424.4521 . 2 2 1 1 2 3
 424.4521 . 2 2 1 1 2 3
 424.4521 2 2 1 1 1 1 4
 424.4521 2 2 2 1 1 1 4
 424.4521 2 2 2 1 1 1 4
 424.4521 . 2 1 1 1 1 4
 277.2007 . 2 2 1 . . .
 277.2007 1 2 1 1 1 2 3
end
label values feedingscheme feedingscheme5
label def feedingscheme5 1 "nfscheme", modify
label def feedingscheme5 2 "fscheme", modify
label values race race5
label def race5 2 "African", modify
label values gender gender5
label def gender5 1 "Male", modify
label def gender5 2 "Female", modify
label values geo geo5
label def geo5 1 "Rural", modify

Please advise.

Regards
Nthato