title: Use esttab to generate summary statistics by group with columns for mean difference and significance
body: <p>I would like to use <code>esttab</code> (<code>ssc install estout</code>) to generate summary statistics by group with columns for the mean difference and significance. It is easy enough to generate these as two separate tables with <code>estpost</code>, <code>summarize</code>, and <code>ttest</code>, and combine manually, but I would like to automate the whole process.</p>
  
  <p>The following code generates the two components of the desired table.</p>
  
  <pre><code>sysuse auto, clear
  
  * summary statistics by group
  eststo clear
  by foreign: eststo: quietly estpost summarize ///
      price mpg weight headroom trunk
  esttab, cells("mean sd") label nodepvar   
  
  * difference in means
  eststo: estpost ttest price mpg weight headroom trunk, ///
      by(foreign) unequal 
  esttab ., wide label   
  </code></pre>
  
  <p>And I can print the two tables and cut-an-paste into one table.</p>
  
  <pre><code>* can generate similar tables and append horizontally
  esttab, cells("mean sd") label
  esttab, wide label
  
  
  * manual, cut-and-paste solution
  -------------------------------------------------------------------------------------------------------
                                (1)                       (2)                         (3)                
  
                               mean           sd         mean           sd         
  -------------------------------------------------------------------------------------------------------
  Price                    6072.423     3097.104     6384.682     2621.915         -312.3         (-0.44)
  Mileage (mpg)            19.82692     4.743297     24.77273     6.611187         -4.946**       (-3.18)
  Weight (lbs.)            3317.115     695.3637     2315.909     433.0035         1001.2***       (7.50)
  Headroom (in.)           3.153846     .9157578     2.613636     .4862837          0.540**        (3.30)
  Trunk space (.. ft.)        14.75     4.306288     11.40909     3.216906          3.341***       (3.67)
  -------------------------------------------------------------------------------------------------------
  Observations                   52                        22                          74                
  -------------------------------------------------------------------------------------------------------
  t statistics in parentheses
  * p&lt;0.05, ** p&lt;0.01, *** p&lt;0.001
  </code></pre>
  
  <p>It seems that I should be able to get the desired table with one <code>esttab</code> call and without cutting-and-pasting, but I can't figure it out. Is there a way to generate the desired table without manually cutting-and-pasting?</p>
  
  <p>I would prefer to output a LaTeX table, but anything that eliminates the cutting-and-pasting is a big step, even passing through a delimited text file.</p>