**** Exporting the results ****
* There are several ways to get your results from Stata into apps like Excel or LaTeX. The most obvious but least clean is copy-and-paste.
* Don't forget about being able to drop into the "shell"
* How might you get nice tables from Stata and into Excel or LaTex form?
* 2 options: outreg2 in Stata or excel2latex macro for Excel
sysuse cancer, clear
reg died studytime age
estimates store A
reg died age drug
estimates store B
reg died studytime drug
estimates store C
reg died studytime age drug
estimates store D
* get out output:
outreg2 using OLSresults, replace see bdec(3) addstat(R-squared by hand, e(r2), Log Lik, e(ll))
outreg2 using myfile, e(all)
* get out summary stats:
outreg2 using summstats, replace sum
* get out correlation tables (change file extension from .tex to .rtf to open in MS Word)
* might need run "findit estout"
estpost correlate died studytime age,matrix
est store corr_table
esttab corr_table using correlation.tex, unstack not noobs compress title(Correlation matrix) nonumbers replace
* say we had estimates stored in tables A, B, and C like earlier, how do we get them out?
outreg2 [A B C D] using EstimatesOut, replace see
* Import the results of these files into Excel using (1) import as "Delimited" (2) choose Tab as the Delimiters (3) Choose Text as Column data format
* To get into LaTex form, simply put a "tex" option on any of the commands above
* ...this is really cool...
outreg2 using mytexfile, tex replace
!texify -p -c -b --run-viewer mytexfile.tex
*There are several types of commands to output data. First, to display only on the screen:
*estout: only displays different types of results on the screen
* see the following article in the Stata Journal (2005):
* http://www.stata-journal.com/article.html?article=st0085
*Alternatively, you can output your results into many types of file formats as follows...
*esttab: outputs estimates, regs, summ stats, or correlations into TXT or RTF (for MS Word)
*outreg2: outputs estimates, regs, summ stats (but not correlations) into DOC, XLS, TEX, or TXT
*outsheet: outputs into XLS (comma- or tab-delimited)
*outfile: outputs into ASCII
*mat2txt: outputs a matrix into TXT
*outtable: outputs a matrix into TEX