*! version 2.1.0 9/8/94 sg30: STB-23 * Edward Whitehouse Institute for Fiscal Studies pr def lorenz version 3.1 local varlist "req ex max(1)" local if "opt" local in "opt" local options "B2title(string) L1title(string) OFfset TItle(string) YLAbel(string) XLAbel(string) *" local weight "fweight" parse "`*'" confirm new var _share _perc _sort _use if "`l1title'" == "" {local l1title "cumulative proportion of `1'"} if "`b2title'" == "" {local b2title "cumulative proportion of sample"} if "`title'"=="" { local title " Lorenz curve"} if "`offset'"=="" { local axis "noaxis xline(0,1) yline(0,1)" } if "`ylabel'"=="" { local ylabel "ylab(0,.25,.5,.75,1)" } else if "`ylabel'"=="." {local ylabel} else local ylabel "ylabel(`ylabel')" if "`xlabel'"=="" { local xlabel "xlab(0,.25,.5,.75,1)" } else if "`xlabel'"=="." {local xlabel} else local xlabel "xlabel(`xlabel')" quietly { gen byte _use=1 `if' `in' gen _sort = -`varlist' if _use==1 sort _sort su `varlist' [`weight'`exp'] if _use==1 local wt : word 2 of `exp' if "`wt'"=="" {gen _share = sum(`varlist'/(_result(1)*_result(3))) if _use==1 gen _perc = [_n]/_result(1) if _use==1} if "`wt'"~="" {gen _share = sum(`varlist'*`wt'/(_result(1)*_result(3))) if _use==1 gen _perc = sum(`wt'/_result(1)) if _use==1} gr _perc _share _share if _use==1, b2ti("`b2title'") ti("`title'") l1ti("`l1title'") c(ll) s(ii) `xlabel' `ylabel' `axis' `options' drop _perc _share _use _sort end