I have a problem aligning the columns with dtable. Using the example from The Stata Blog » Creating tables of descriptive statistics in Stata 18: The new dtable command
The results for each by variable are right aligned within each by category
but I would like all the results to be equally spaced and aligned within the category.
Thank you.
Eddy
Code:
webuse idu, clear
dtable, by(male, tests testnotes nototal) ///
sample(, statistic(frequency proportion) ///
place(seplabels) ) continuous(age, statistics(mean minmax) test(kwallis)) ///
continuous(ltime rtime, statistics(mean skewness kurtosis) test(poisson)) ///
factor(needle, statistics(fvfrequency fvproportion)) ///
factor(jail inject, statistics(fvfrequency) test(fisher)) ///
define(minmax = min max, delimiter(-)) nformat(%9.1f mean minmax) ///
sformat("(%s)" fvproportion minmax proportion) ///
nformat(%9.2f proportion fvproportion)
collect style header male, title(hide)
collect label levels male 0 "Female", modify
collect label levels male 1 "Male", modify
collect style cell var[rtime 1.needle 1.jail], border( bottom, width(1))
collect style cell male[_dtable_test], shading( background(lightyellow)) ///
font(, bold)
collect notes "Kruskal–Wallis rank test performed for age."
collect notes "Poisson regression main effects test performed for ltime and rtime."
collect notes "Pearson's chi-squared test performed for needle."
collect notes "Fisher's exact test performed for jail and inject."
collect preview
Code:
Age (in years) 28.8 (18.0-46.0) 31.7 (17.0-52.0) 0.002 Last time seronegative for HIV-1 22.1 -0.305 2.017 24.3 -0.353 2.251 <0.001 First time seropositive for HIV-1 12.0 0.951 2.285 14.4 0.749 3.024 0.020
Thank you.
Eddy

Comment