Add current date to Stata file names (and others)

We wrote earlier about how to add time stamps (current date and/or time) to your Stata figures, e.g. to keep track of work in progress results. A similar strategy can be used when storing log-files, which are typically overwritten with a more recent version of the same log.

Continue reading “Add current date to Stata file names (and others)”

Use of embedded quotation marks within locals in Stata

Proper use of single and double quotation marks is essential when working in Stata, especially when writing loops where locals can be a huge time and memory saver. The use of single and double quotation marks is rather straightforward (using ` and ‘ for single, and ” for double quotation marks). You can rather easily define a local, e.g. based on the average of a variable

Continue reading “Use of embedded quotation marks within locals in Stata”

Add date, month or year to your LaTeX document

Including the current date in your LaTeX document is quite straightforward. Simply put \today whereever you want the current timestamp (i.e. the date at the time of compiling the document), and you get the current date:

Continue reading “Add date, month or year to your LaTeX document”

Add document properties in PDF using LaTeX

You might have seen that PDF documents have (as many other files as well) their own document properties, such as the document’s author, title, etc. Using LaTeX’s hyperref package, you can very easily define these in the preamble of your .tex-document:

Continue reading “Add document properties in PDF using LaTeX”

Handout-mode in LaTeX slides

Whether it is lecture slides or presentations, you often wants to distribute pdf-versions of your beamertex file. If you are using overlay to blockwise show text or blockwise highlighting parts of tables (see here and here for ways to color parts of tables with overlay), it makes little sense to distribute the pdf versions where one and the same slide is repeated with each overlay step. Luckily, there is a extremely simple solution

Continue reading “Handout-mode in LaTeX slides”

Supress labels in Stata figures

Supress legend elements in multiple Stata twoway figures

A great feature of Stata figures is that you can mix several plot types in one by using the twoway (...) (...) command. If you have several plots merged into one twoway graph and also want to add a legend, the legend might become a bit crowded. In the following example, legends are specified with the , legend(lab(1 "Scatter 1") lab (4 "Scatter 2")) option because I only wanted to mark the diamonds and circles in the legend:

Continue reading “Supress labels in Stata figures”

Produce multiple pdfs in LaTeX with automated cross-references

Create reference between documents (paper, letter to editor etc) with direct quotes.

For some time I looked for a way to simplify the process of linking LaTeX files of my manuscripts with the replies to editors and referees. In particular, I was looking for a way to automatically update cross-references (i.e. to put a \ref in the replies and link it to a \label in the mansuctipt – for example for a table), and also to put direct quotes of the from the main text into a report (e.g. if you want to tell the editor/referee if you have a specific sentence, paragraph or even table added to the revised manuscript).

Continue reading “Produce multiple pdfs in LaTeX with automated cross-references”

Remove blanks from string variables in Stata

Identify and remove blank space in Stata’s string variables

When dealing with string variables in Stata, blanks spaces can make it difficult to identify values. For example, if a variable contains " Arizona", a command that contains an if command such as ... if state="Arizona" won’t detect this observation.

Continue reading “Remove blanks from string variables in Stata”

Combining strings into one variable

I’m again playing around with strings in Stata and need to combine (string) variables with (string) variables as well as strings in locals with string variables. Suppose you have two string variables (strvar1 and strvar2) and want to combine them, you can simply type

Continue reading “Combining strings into one variable”

Three ways to import references into your BiBTeX database

Manually importing references into your BiBTeX database can be tedious (and prone to make errors…). While you can download the BiBTeX code from the journal websites or other sites such as IDEAS, there are three four other useful ways to efficiently update your BiBTeX database

Continue reading “Three ways to import references into your BiBTeX database”