Hi Statalisters,

having a real struggle figuring this one hope - really hope someone can help!

I am generating some simple weighted summary stats to export into excel. I need to include tertiles (p33, p66) in the analysis but sum, d doesn't include that breakdown.

Does anyone know of any alternative way of doing it? My current code is:


Code:
eststo: estpost sum _begin-_end  [w=wtg_sch], d
    esttab . using "${fn}" , append unstack cells("count mean sd p10 p50 p90") nonumb noobs ///
    varwidth(0) label ///
    title("All Schools") varlabels(`e(labels)') ///
    prehead("$S_DATE" "Summary Statistics" "@title" "`=cond($impute_yes==1,"$imp_yes","$imp_no")'" "-") 


* in which my task is to include p33 and p66 in the cells
I was thinking about generating a new variable for each statistic, so like:

Code:
_pctile  VAR , nq(3)
ret li
gen p33 = `r(r1)'
gen p66 = `r(r2)'
But these aren't weighted, and I'm not sure how to create the weighted variable? Any help would be much appreciated!!
Best,

Chris Burningham