Announcement

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

  • Creating custom .tex tables from results stored in .dta

    Hello,
    I am wondering if there's a good way to get results from .dta to .tex.

    I've been storing my (synthetic control method) results in a .dta file and then manually typing them into .tex, but I'd like to automate this process.

    This is what my results in Stata look like:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str18 var float(treatment_effect pval actual_deaths synth_deaths)
    "deaths"          .3891718 .02 977 795
    "male_deaths"     .6172195 .02 704 560
    "white_deaths"    .5928732 .02 873 634
    "female_deaths"    .219206 .16 273 222
    "nonwhite_deaths" -.280511  .2 104 122
    end

    I want to automate the process of getting them into the following .tex table:


    \begin{table}[h]
    \centering
    \begin{threeparttable}
    \centering
    \caption{Table 2}
    \label{main_results}
    \begin{tabular}{cccc}
    \toprule
    & Monthly ATT & Actual Deaths & Synthetic Deaths \\
    \midrule
    All Deaths & 0.39** & 977 & 795 \\
    & (0.02) & & \\
    White Deaths & 0.59** & 873 & 634 \\
    & (0.02) & & \\
    Non-white Deaths & -0.28 & 104 & 122 \\
    & (0.20) & & \\
    Male Deaths & 0.62** & 704 & 560 \\
    & (0.02) & & \\
    Female Deaths & 0.22 & 273 & 222 \\
    & (0.16) & & \\
    \bottomrule
    \end{tabular}
    \begin{tablenotes}\footnotesize
    \item[a] Table description: This table shows my main results.
    \item[b] Numbers in round brackets are p-values obtained from the in-space placebo tests.
    \item[c] \sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)
    \end{tablenotes}
    \end{threeparttable}
    \end{table}


  • #2
    I like to save the results in globals and create the table using texdoc, like: https://twitter.com/toddrjones/statu...13432326438913. It's definitely not fully automatic, but it has the advantage of allowing you to get the table exactly how you want it every time.

    Comment


    • #3
      Code:
      ssc install texsave, replace
      help texsave

      Comment


      • #4
        Thanks both! Todd, this is the kind of thing I had in mind; I'll give it a try!

        Comment

        Working...
        X