My dear colleague Anders Stenberg recently taught me a very nice trick to include numbers (such as: number of observations, R2s or any other number that can be saved to a local) in Stata figures. While including numbers can be simply done with a local, the trick is to have them nicely formatted. I.e., to include commas in a larger number, or to have decimals rounded.
In the example that follows, the variable of interest is “aht”, of which I want to produce a histogram with mean and underlying number of observations in a subtitle
quietly sum aht, det
local n = trim("`: display %11.0gc r(N)'")
local mean = trim("`: display %09.3g r(mean)'")
twoway (hist aht), title("Histogram of AHT" "(N=`n'; Mean = `mean')")
Note that the trim is optional, but helps to avoid unwanted spaces in the subtitle.
With format applied
Without format applied
For more information on how to format output, also check
One big disadvantage of writing in LaTeX compared to writing in other software, such as Word, is that its absence of track changes. Although there are ways to do track changes, such as the online tex-editor Sharelatex or the trackchanges package, I have sticked to commenting out deleted parts of the text, or by highlighting new passages in red.
I just came across this cool website on which you can compare different tex codes, e.g. before and after one of your co-authors worked on a text. On this website, you simply paste the original and the revised version, and you will receive a tex-code to generate a “track changes” document, which exactly highlights deleted and new text.
Follow this link to get compare your documents: https://3142.nl/latex-diff/
I just ran across a very useful ado.-file called use13 which allows to open files in Stata 12 which were originally saved in Stata 13 (which often results in the error code “r(610): file not Stata format”). use13 can be installed by typing
ssc install use13
This will then convert the Stata13 data file to use in Stata12.
Note: An alternative to use13 is to use saveold when creating the data file in Stata 13 (instead of save):
saveold filename [, saveold_options]
While you can simply drag & drop images in MS Word or Powerpoint, doing this in Latex requires a few more steps. An important difference is that in Latex, you first need to save the copied file as a separate image file which can then be included in the Latex code. For this purpose, we need a decent image editor. I recommend using Continue reading
I just came across a very simple way to retrieve the full BibTex-Code from DOI. Just copy the DOI of a paper you want to cite and paste it into the search field of this website: http://www.doi2bib.org/
There are a lot of sources giving advice on how to format your Latex tables. Adrian P. Robson (email@example.com) wrote a very good and comprehensive guide on formatting tables in Latex. Just follow the following link to download the PDF file:
LATEX Table Hints and Tips (by Adrian P. Robson, firstname.lastname@example.org)
Stata Corp. announced a channel on YouTube. Yes, I know, it is not exactly television, but you can lean back and watch videos on how to do something with Stata.
Here is the link