I am trying to build a table that displays mean (with standard deviation in row below) by treatment group followed by a column for the p-value from a t-test for difference in mean followed by a column that has the mean of the total sample (standard deviation below). My problem is I can't get the p-value to be in the same row as the mean. It ends up in a third row below the standard deviation of the variable. The following is an example of my code currently and what it produces.
What I want is the p-values in the same row as the means. I'm aware of the ability to use quotes or in parentheses in cells to gather elements and place them in the same row. But for whatever reason when I try to do that I end with extra columns between the columns with data.
Code:
sysuse auto, clear eststo forn : estpost sum price mpg if foreign == 0 eststo dom : estpost sum price mpg if foreign == 1 eststo tot : estpost sum price mpg eststo diff : estpost ttest price mpg, by(foreign) unequal esttab forn dom diff tot, /// prehead("\begin{tabular}{l*{4}{c}} \\ [-1.8ex]\hline \hline \\[-1.8ex] " /// "& \multicolumn{1}{c}{Foreign} & \multicolumn{1}{c}{Domestic} & " /// "\multicolumn{1}{c}{p-value} & \multicolumn{1}{c}{Total} \\ ") /// main(mean) aux(sd) nostar unstack label booktabs nonum /// collabels(none) f noobs nomtitle nogaps /// cells(mean(fmt(0 3)) sd(fmt(0 3)par) p(fmt(3)) ) /// postfoot(" \hline \hline \\[-1.8ex] \end{tabular}")
What I want is the p-values in the same row as the means. I'm aware of the ability to use quotes or in parentheses in cells to gather elements and place them in the same row. But for whatever reason when I try to do that I end with extra columns between the columns with data.
Comment