Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Stata's esttab, add dollar sign to cell format, export to Latex

    My advisor wants me to add dollar signs to my table of summary statistics. I generate this table and export it to Latex using Stata's esttab command.
    I need to 1) Add dollar signs to some of the results cells (not all) and 2) Make sure that Latex can handle the dollar signs.
    I think that 2 might be accomplished using the substitute option, but I can't figure out how to do 1. Here is some minimal code that I am trying to use to solve this problem.
    Code:
      
    sysuse auto, clear  
    estpost summarize price mpg weight length if foreign==0
    est store A
    estpost summarize price mpg weight length if foreign==1
    est store B  
    esttab A B  using $root/Outputs/test.tex, replace ///  //a file path on my machine
    cells("mean (fmt(%9.0fc %9.2fc %9.0fc))" "sd(par fmt(%9.0fc %9.2fc %9.0fc))") ///
    mtitle("Domestic" "Foreign") ///
    mgroups("Type", pattern(1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat( \cmidrule(lr){@span})) ///
    nonumber booktabs f label  collabels(none)  
    eststo clear
    This produces:
    Code:
      
                         &\multicolumn{2}{c}{Type} \\\cmidrule(lr){2-3}
                         &\multicolumn{1}{c}{Domestic}&\multicolumn{1}{c}{Foreign}\\
    \midrule
    Price               &       6,072&       6,385\\
                        &     (3,097)&     (2,622)\\
    Mileage (mpg)       &       19.83&       24.77\\
                        &      (4.74)&      (6.61)\\
    Weight (lbs.)       &       3,317&       2,316\\
                        &       (695)&       (433)\\
    Length (in.)        &         196&         169\\
                        &        (20)&        (14)\\
    \midrule
    Observations        &          52&          22\\
    I'd like to get it so the output would have \$ in front of the 6,072 and the 6,385
    I see some discussion on the Statalist regarding workarounds for graphs, but nothing for esttab. Someone also mentions creating "custom formats" but I can't seem to find documentation on that anywhere.

    This is crossposted to StackExchange: http://stackoverflow.com/questions/4...xport-to-latex
    Last edited by Danielle Vance; 18 Apr 2017, 09:46.

  • #2
    Maybe a silly remark, but I'd consider just adding the dollar signs manually in your .tex file? I've personally found esttab to be useful to get the main framework, but any details are easier to fix in Latex itself. You can add a dollar by typing \$ instead of $

    Comment


    • #3
      Yeah, that will be my last ditch solution. But I would really love a solution that automates the process and is reproducible.

      Comment


      • #4
        Others are more experienced with esttab, but I feel it will be very difficult to get there - especially because you do not want dollar signs in all cells. One thing I've done at some point is to just write the Stata code myself. As in, noisily display the latex code, using if statements and qualifiers to adjust it as required. But as I said, in most cases it's not easier than doing the adjustments yourself, especially with some smart find and replacing.

        Comment


        • #5
          I hear your point. I guess I was just hoping there was something in the options of the fmt command that I was missing. Or perhaps there was a user-written package that allows one to add a custom format, etc.

          Comment

          Working...
          X