title: How do I create a difference in means table with a column for N observations using esttab?
body: <p>I'm trying to create a table showing the difference in means of two groups but I'm struggling to get exactly the right columns. I'm specifically trying to recreate a table that includes a column indicating N. I'm really confused how I would go about doing this. Here's the code for the bulk of the kind of table I'm talking about:</p>
  <pre><code>sysuse auto, clear
  
  eststo all: quietly estpost summarize ///
      price mpg weight headroom trunk
  eststo domestic: quietly estpost summarize ///
      price mpg weight headroom trunk if foreign == 0
  eststo foreign: quietly estpost summarize ///
      price mpg weight headroom trunk if foreign == 1
  eststo diff: quietly estpost ttest ///
      price mpg weight headroom trunk, by(foreign) unequal
  
  esttab all domestic foreign diff, ///
  cells(&quot;mean(pattern(1 1 1 0) fmt(2)) b(star pattern(0 0 0 1) fmt(2))&quot; &quot;sd(pattern(1 1 1 0) par fmt(2)) t(pattern(0 0 0 1) par fmt(2))&quot;) ///
  label
  </code></pre>
  <p>In this scenario, I want a column N that just lists 74 in each row. In this shortened example, it doesn't make much sense but I'm using multiple data sources with the same variables and I want to stack the difference in means tables together.<a href="https://i.stack.imgur.com/AXsxs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AXsxs.png" alt="output" /></a></p>