Supress labels in Stata 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

Check whether variable exists in if-conditions

In some applications, e.g. if you want to save coefficient estimates from a regression with many dummies (e.g. fixed effects), you might want to store coefficients as estimates. In this example, we are interested in storing the estimates of the GROUPVAR dummies, but not the dummies of OTHERVAR. While this is usually straightforward by writing

Continue reading

Add time stamp to Stata figures

Especially in the early stages of a research project it might be good to “time stamp” figure so that you can later figure out when you created a certain figure. Of course you could just check the date in the explorer / finder, but you can also simply add a note to the figure with time and date of its creation:

Continue reading

Formatting text in Stata figures

This is not really new, but still comes in handy when formatting text in Stata figures. With a relatively simple code, you can make write text bold, in italics, and even greek letters

This special text is entered in curly brackets “{…}”:

  • Greek letters: {&alpha}, {&beta}, etc.
  • Text in italics: {it:Text in italics}
  • Text in bold: {bf: Text in bold}
  • Operators: {&le} (less than or equal to), {&ne} (unequal)
  • Subscripts and superscripts: e.g., write y{sup:2}{sup:ij}