Is there a way to generate a table using dtable, with rows sorted in descending order? Essentially what's achieved with
.
Code:
tab var , sort
webuse auto, clear * using tabulate tab rep78, sort * Reorder categorical variable myaxis rep78_sorted = rep78, sort(count) descending * using dtable dtable i.rep78 dtable i.rep78_sorted
. dtable i.rep78 ----------------------------- Summary ----------------------------- N 74 Repair record 1978 1 2 (2.9%) 2 8 (11.6%) 3 30 (43.5%) 4 18 (26.1%) 5 11 (15.9%) ----------------------------- . dtable i.rep78_sorted ----------------------------- Summary ----------------------------- N 74 Repair record 1978 3 30 (43.5%) 4 18 (26.1%) 5 11 (15.9%) 2 8 (11.6%) 1 2 (2.9%) -----------------------------
unab temp_symptoms: sym* foreach symp of local temp_symptoms { local symptoms = "`symptoms' 1.`symp'" } dtable num_symp `symptoms', /// by(path, notests) nformat(%9.1fc p50 p25 p75) /// title(Table 1c. Symptomatology by Tumor Type) titlestyle(font(,size(10))) /// notestyle(font(,size(6))) fix_dtable_total path collect style cell, font(,size(8)) collect style header `temp_symptoms', level(hide) collect style putdocx, layout(autofitc) halign(center)
vorter
unab temp_symptoms: sym* foreach symp of local temp_symptoms { local symptoms = "`symptoms' 1.`symp'" } vorter - (sum) `temp_symptoms', after(num_symp)
Comment