Using the auto dataset as a simple example, I have the following do file:
which produces the following table:
I would like to place headings in the middle of the rows - for this (yes, it's silly) example, I would like to place "quantitative variables", preceded by a blank line above the row for "Price" and then I would like to place a blank line and "categorical variables" above "Repair record 1978"
I would also like to move the results in the "N" row to above the second horizontal line (so the N's and %'s appear under "Domestic" and under "Foreign" but above the horizontal line that is now directly under Domestic and Foreign (the line would still be there but now below the N's and %'s)
Code:
sysuse auto, clear
local convars price mpg
local catvars rep78
noi dtable, by(foreign, tests nototals nomissing) ///
column(by(hide)) ///
continuous(`convars') nformat(%5.1f mean sd) ///
factor(`catvars', ///
statistics(fvfreq fvpercent) ///
test(pearson)) ///
sformat("N=%s" frequency) ///
collect addtags roweq[Demographics], fortags(var[`convars'])
foreach b of local catvars {
collect addtags roweq[`b'], fortags(var[i.`b'])
}
exit
Code:
. run "/Users/rich/Documents/Stata/testtbl.do"
note: using test regress across levels of foreign for price and mpg.
note: using test pearson across levels of foreign for rep78.
---------------------------------------------------------
Domestic Foreign Test
---------------------------------------------------------
N N=52 (70.3%) N=22 (29.7%)
Price 6072.4 (3097.1) 6384.7 (2621.9) 0.680
Mileage (mpg) 19.8 (4.7) 24.8 (6.6) <0.001
Repair record 1978
1 2 (4.2%) 0 (0.0%) <0.001
2 8 (16.7%) 0 (0.0%)
3 27 (56.2%) 3 (14.3%)
4 9 (18.8%) 9 (42.9%)
5 2 (4.2%) 9 (42.9%)
---------------------------------------------------------
I would also like to move the results in the "N" row to above the second horizontal line (so the N's and %'s appear under "Domestic" and under "Foreign" but above the horizontal line that is now directly under Domestic and Foreign (the line would still be there but now below the N's and %'s)

Comment