I would like to create a bar graph (with error bars) that dísplays the values (finr) for two categories of a multiple categorical variable (vtype) on the y-axis with separate values based on the 0/1 values of dummy (at3) for each of these percentiles (5, 10, 25, 50, 75, 90, 95) displayed along the x-axis. I can get close to what I want with:
Code:
graph bar (p5) finr (p10) finr (p25) finr (p50) finr (p75) finr (p90) finr (p95) finr ///
if inlist(vtype, 2, 3), over(at3) over(vtype) yti("") yla(0(500000)1500000) ti(Financial assets, size(small)) ///
legend(lab(1 "5th") lab(2 "10th") lab(3 "25th") lab(4 "50th") lab(5 "75th") lab(6 "90th") lab(7 "95th") col(7))
though I still need to add the error bars. I also tried to replace the (busy) legend with x-axis labels but Stata responded with "xlabels(1 5th" 2 "10th" 3 "25th" 4 "50th" 5 "75th" 6 "90th" 7 "95th") not allowed, " invalid name (r(198));". I came across -cibar- (ssc install cibar), and while it provides confidence intervals, I could not find a way to add percentiles to the x-axis.

Finally, I 'found' -statsby- mentioned by Nick Cox in https://www.statalist.org/forums/for...way-bar-graphs and explained in https://www.stata-journal.com/sjpdf....iclenum=gr0045 - please refer to my initial explanation and code using -graph bar- to understand my intent, the following is an initial attempt
Code:
statsby p5=r(p5) p10=r(p10) p25=r(p25) p50=r(p50) p75=r(p75) p90=r(p90) p95=r(p95) upper=r(ub) mean=r(mean) lower=r(lb) if inlist(vtype, 2, 3), ///
by(vtype at3) saving(finr_ci, replace) 
twoway rcap ub lb finr || scatter mean finr, yti() xti("percentiles") xla(1 "5th" 2 "10th" 3 "25th" 4 "50th" 5 "75th" 6 "90th" 7 "95th") legend(off) > subtitle(95% confidence intervals for mean, place(w))
Sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float finr byte(at3 vtype)
117951.12 0 2
 235799.2 1 3
 208530.8 1 3
305687.22 0 3
253412.14 0 3
 413083.6 0 3
280980.72 0 3
28540.285 0 3
  323.646 0 3
223375.38 1 3
147438.67 1 3
 379603.6 0 3
 715984.1 0 3
 515115.4 0 3
581753.56 0 3
 458876.3 0 3
   534214 1 3
 367631.5 1 3
 490251.7 1 3
111402.04 1 3
118890.35 1 3
 95747.05 1 3
 611670.6 1 3
   772532 1 2
1085729.4 1 2
2158285.5 1 2
 82337.68 0 2
105099.09 0 2
 118543.2 0 2
239144.95 1 2
   253273 1 2
 208199.4 1 2
 125484.6 1 2
 365277.2 1 2
 64402.76 1 2
 11397.52 1 2
 204755.6 1 2
 194343.6 1 2
   179749 1 3
end