Category: Stata

Blockwise copy & paste in Stata
Simple method to clockwise edit text in dofiles

Overlaying histograms in Stata
For analysing data and comparing distributions, I often want to overlay two histograms. Without further options, however, one distribution usually overlays the other and makes comparisons cumbersome. It is possible to set a few options to make the figure look nice.

Formatted numbers in figure (sub)headers
There is a very nice and simple 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 […]

Data storage type matters
Despite most sources tell that the storage type in stata should not matter, it is worth checking whether this is the case for your dataset. I just came across a situation where two identically constructed datasets (one stored in default type (float) and one stored in double) generated different output. Also before that i encountered […]

Greek Letters in Stata Graphs
There is a rather easy way of including Greek letters in Stata figures. Greek letters are written in the following way: $latex \beta$ = {&beta}

Preamble when switching between OS X and Windows
A problem when working on one and the same project on different platforms (here: Windows and Mac/OS X) is that pathnames differ. There are two straightforward solutions to this: 1) When defining a number of different path (e.g. one path where data is stored, one where results/output is stored), it is handy to define the paths […]

Stacked graphs in Stata
For plotting the relative importance of (e.g.) input shares, it can be useful to stack them in a figure. In my specific problem, I wanted to show the development of low, medium, and highskilled labour inputs, relative to all labour inputs over time. Since the three shares obviously sum up to 1, I wanted to […]

Manipulating variable labels
Occasionally we want to use variable labels in loops or we want to apply them to other labels. a very simple local syntax function for that is local localname: variable label varname. As an example, suppose that I have three variables (x, y, z) with their respective labels. I want to create three other variables […]

Include Stata figures in Latex
Just found an easy way to include figures from Stata into Latex by converting Statafigures to PDFfiles first. Just use the following codes:

Wald test
In order to perform a wald test in stata, you can simply use the “test” command.