Giter VIP home page Giter VIP logo

panelcombine's Introduction

PanelCombine

Stata programs to combine LaTex output files from esttab and sutex into single, ready-to-include LaTex-formatted tables with multiple panels

Use

Panelcombine

Program for combining production-ready regression tables from esttab ... ,style(tex) User outputs (writes to disk or tempfile) multiple files intended to form multiple panels of the same table. Program then takes multiple files and trims the extraneous leading/trailing code and inputs specified panel titles

Syntax:

panelcombine, use(filenames) paneltitles(strings) columncount(integer) save(filepath) [CLEANup]

MWE:

sysuse auto, clear
local count = 1
foreach sample in "" "if foreign==1" "if foreign==0" {
eststo clear
foreach set in "mpg" "mpg trunk" "mpg trunk headroom" "mpg trunk headroom length" {
eststo: regress price `set' `sample'
estadd ysumm
}
esttab _all using Panel`count'.tex, style(tex) keep(mpg)  ///
stats(N r2 ymean ysd, fmt( %9.0g %9.2f  %9.2f %9.2f) ///
labels("\$N$" "\$R^2$" "Mean of outcome" "St. dev. of outcome")) label  ///
drop() replace se r2 star( * .1 ** .05 *** .01) b(%9.5f) se(%9.5f) ///
mtitles("\makecell{Base\\ (1)}" "\makecell{+trunk\\(2)}" "\makecell{+headroom\\(3)}" "\makecell{+length\\(4)}"   ) ///
nonotes addnotes("\begin{minipage}{.8\linewidth} \footnotesize \smallskip \textbf{Note:} Table reports regression estimates about cars. Significance levels are indicated by $*$ $<.1$, ** $<.05$,  *** $<.01$.   \end{minipage}" )
local ++count
}
include "https://raw.githubusercontent.com/steveofconnell/PanelCombine/master/PanelCombine.do"
panelcombine, use(Panel1.tex Panel2.tex Panel3.tex)  columncount(5) paneltitles("Full sample" "Foreign cars" "Domestic cars") save(combined_table.tex) cleanup

Then in LaTeX (specific esttab output used above requires makecell and caption packages):

\begin{table}[H] \centering \caption{Table title} \label{tablelabel}
\input{combined_table.tex}
\end{table}

Panelcombinesutex

Program for combining production-ready summary statistics tables from sutex ... ,style(tex)

Syntax: panelcombine, use(filenames) paneltitles(strings) columncount(integer) save(filepath) addcustomnotes(str asis) [CLEANup]

MWE:

sysuse auto, clear
local count = 1
foreach sample in "" "if foreign==1" "if foreign==0" {
sutex price mpg headroom weight length turn displacement gear_ratio `sample', labels minmax file("sumstatsP`count'.tex")  title("Summary statistics") replace
local ++count
}

include "https://raw.githubusercontent.com/steveofconnell/PanelCombine/master/PanelCombineSutex.do"
panelcombinesutex, use(sumstatsP1.tex sumstatsP2.tex sumstatsP3.tex) ///
paneltitles("Full sample" "Foreign cars" "Domestic cars") columncount(5) save(sumstats.tex) ///
addcustomnotes("\begin{minipage}{`linewidth'\linewidth} \footnotesize \smallskip \textbf{Note:} Table shows summary statistics for cars in different estimation samples.\end{minipage}" ) cleanup

Then in LaTeX (table environment already included in output; makecell and caption needed again):

\input{sumstats.tex}

Notes

  1. files used will appear in the table in the order they are input; similarly, paneltitle are indexed to the files used based on the order they are entered into the option string
  2. File written automatically overwrites existing file (replace option is automatically applied)
  3. panelcolumns option specified the number of columns for the panel titles to span, although they are automatically left-justified
  4. Panels are automatically prefixed with Panel A: [paneltitle1], Panel B: [paneltitle2], Panel C: [paneltitle3]...

Potential improvements

  1. justification option for panel titles (currently left only)

Contributing

I am happy to recieve general critique, suggestions or bug fixes on the code, or otherwise...

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

panelcombine's People

Contributors

steveofconnell avatar

Stargazers

Junjie Ren avatar Omer Sarigul avatar Pablo Garriga avatar Corey Rusko avatar jbx avatar  avatar Raviv M-G avatar  avatar  avatar Gen Li avatar Aaditya Dar avatar William Buchanan avatar Frank Qu avatar

Watchers

James Cloos avatar  avatar

panelcombine's Issues

Panel name not working with esttab's title option

Hi Stephen,

Thank you very much for this package. This is very helpful. However, I find that when using esttab to make tables and option "title()" is specified, the panelcombine result doesn't show the first panel name. Can you replicate this on your side?

Thanks,
Junxi

/ is not a valid command name r(199)

Dear Steve,
Many thanks for creating this comment which would do exactly what I need.
However, for now I am not able to make it work.
After installation, when I run the example file "ExampleUse.do" I get the following error:
" / is not a valid command name
r(199);"
I ran on both Stata MP 15 and MP 16 on windows.
Many thanks in advance for your help
Best regards
Clara

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.