Dear Statalist community,

I would like to calculate weighted confidence intervals of the median, which I need to use for a descriptive graph (median wealth and associated confidence intervals graphed by marital status group and gender).

Currently I am using the following command, which unfortunately cannot handle weights:

Code:
statsby median=r(c_1) upper=r(ub_1) lower=r(lb_1), by(mar_di_pro2 female) saving(medianci, replace) : centile wealth
use medianci , clear
I can calculate weighted medians using the following command:
Code:
gen median1 = . 
gen median0 = .

quietly forvalues i = 1/6 { 
    forvalues f=0/1{
        summarize wealth [w=xrwght] if mar_di_pro2 == `i' & female==`f', detail 
        replace median`f' = r(p50) if mar_di_pro2 == `i' & female==`f'
  }
}
But summarize obviously does not provide confidence intervals of the median. Has anyone an idea of how I can obtain weighted confidence intervals of the median (by different groups) and save those in separate variables?

I am using Stata 15 and my data are the German Socio-Economic Panel.

Thanks,
Nicole