Unfortunately we do not have a Stata do file for calculating the Gini coefficient. We use CSPro for producing the tabulations for the DHS reports, and the code is written in CSPro.

You can find an explanation of the calculation of the Gini coefficient in the DHS6 tabulation plan ( http://www.dhsprogram.com/pubs/pdf/DHSM6/Final_Report_Tab_Pl an_05June2013_DHSM6.pdf) starting on page 12.]]>

use "BDHR61FL.DTA", clear * Use a selection here to run this for a specific subgroup * e.g. for urban * drop if hv025!=1 * Summarize and get the minimum and the maximum quietly summ hv271 local w_min = r(min) local w_max = r(max) * Calculating the range local w_range = `w_max' - `w_min' * Create 100 groups gen w_group = int( (hv271-`w_min') / (`w_range'/(100-1)) ) + 1 * Transformed wealth score - 0 based gen wscore_trans = hv271 - `w_min' * Summarize by the 100 groups collapse (sum) pop=hv012 ws=wscore_trans [pw=hv005/1000000], by(w_group) * Accumulate population and wealth scores across groups gen pop_accum = pop replace pop_accum = pop_accum[_n-1] + pop if _n>1 gen wdx_accum = ws replace wdx_accum = wdx_accum[_n-1] + ws if _n>1 * Sum total population and total wealth scores quietly summ pop local pop_tot = r(sum) quietly summ ws local wdx_tot = r(sum) * Calculate proportion in each group for population and wealth gen pop_prop = pop_accum / `pop_tot' gen wdx_prop = wdx_accum / `wdx_tot' * Calculate Gini coefficient elements gen gini = (pop_prop - pop_prop[_n-1]) * (wdx_prop + wdx_prop[_n-1]) if _n>1 * Gini coefficient is 1 - sum of elements, multiplied by 100 to be a percentage quietly summ gini local gini_coeff 100 * (1 - r(sum)) di "Gini coefficient: " `gini_coeff'

If you wanted just the second governorate, for example, use

drop hv024!=2

I could probably make the code work to produce the Gini coefficient by background variables, but it would take rewriting the code in a different way - not using summarize and not using the locals - but it seems easy enough just to add in the drop to select the cases you want.]]>

Bruno]]>

This file is no longer available

Please I need the code and steps to run the command in STATA

Thanks in advance ]]>

The Stata code is already shown in this thread, so I'm not sure what else you need.]]>