I am trying to export a large number of descriptive statistics on household income by country of origin using Ineqdec0 + estout. However, whenever STATA finds missing observations, it interrupts abruptly. Is there a way to avoid this in the loop? Or is there a command to say STATA to keep going if it encounters missing values? I post here the code:
Code:
levelsof country_origin, local(ctry)
foreach l of local ctry{
forvalues j=2005/2011{
set more off
matrix C_`j'_`l' = (0,0,0,0)
forvalues i=1/5{
foreach v of varlist n_hh_income r_hh_income{
ineqdec0 `v' if `v'_qtile_`l' == `i' & year == `j' & country_origin == `l'
matrix Amean = (r(mean))
matrix Asd = (r(sd))
matrix Amax= (r(max))
matrix Agini= (r(gini))
matrix C_`j'_`l' = (C_`j'_`l'\Amean[1,1], Asd[1,1], Amax[1,1], Agini[1,1])
}
}
matrix list C_`j'_`l'
estout matrix(C_`j'_`l') using income.xls, style(tab) omitted legend label title(Average household income per year) modelwidth(10) varwidth(10) append
}
Thank you in advance,
Andrea
0 Response to ineqdec0, missing values and error in loop
Post a Comment