* Before running the following DO file, rename variables "5th percentile", "10th percentile", "95th percentile", "97.5th percentile" and "99th percentile" * according to Stata's naming conventions: the first character of a name must be a letter or an underscore (it is recommended, however, that a variable name * starts with a letter since all of Stata's built-in variables begin with an underscore) encode exposurehierarchyl1, gen(foodex_l1) egen sumy1 = total(mean), by(foodex_l1) generate perc = (mean/ sumy1)*100 gsort food -mean replace perc = -perc bysort food (perc) : gen cum_perc = sum(perc) replace cum_perc = -cum_perc drop sumy1 foodex_l1 replace perc = -perc