Stata Tips

A nice template for your do-files: dotemplate

Introduction to dotemplate If you want to have organized do-files and ado-files and/or stop scrolling up and down looking for a particular section of your long code, you may consider start using the Stata command dotemplate. Basically, this command creates a template for your do-files and ado-files so that you can start off your code on the right foot. Once you’ve downloaded it, type dotempate in Stata and hit Enter.

Dependencies: making sure your ado/do-files run in any computer

Imagine that you write a do-file or an ado-file in which you use one or serveral user-written commands available in SSC (or any other repository). However, when you share it with someone else, that person is constantly frustrated because your code is constantly requesting the use of a command that has not been installed in their computers. You could solve your problem by always adding the following code at the beginning of do/ado-file.

Export results to Tableau or Excel from Stata

This post is part of an updated version of the chapters of the third part of the handbook Poverty and inequality measures in pracitce (2014) internally avaialable at the World Bank intranet. Even though you might be able to do most of your work in Stata, it is sometimes faster and easier to plot some charts in Tableau of Excel. In contrast to other programs like R, Stata does not have an Integrated Development Environment (IDE) like Rstudio or a big community to create amazing packages like shinyR, diagramR, or ggplot2 that may suffice for any kind of graphic representation of results.

Naming Variables

This post is part of an updated version of the chapters of the third part of the handbook Poverty and inequality measures in pracitce (2014) internally avaialable at the World Bank intranet. It is difficult to name a variable such that the name is both easy to remember and clearly captures the variable’s meaning. Here are some easy principles, conventions, and tools that can simplify the process. You may adopt or not these principles, but I have implemented them in my teams and our workflow has improved dramatically.

Working with Loops

This post is part of an updated version of the chapters of the third part of the handbook Poverty and inequality measures in pracitce (2014) internally avaialable at the World Bank intranet. In this post, I provide few tips and better understanding on using loops in Stata. I assume that you already know what a loop is and the main differences between foreach , forvalues , and while loops.

My Stata editor: NotePad++

This post is part of an updated version of the chapters of the third part of the handbook Poverty and inequality measures in practice (2014) internally avaialable at the World Bank intranet. Even though Stata has improved its do-file editor in version 13, it is still not a great tool for programming efficiently. Instead, we recommend using NotePad ++ (NP++). This is an excellent program that provides many useful features for writing Stata code quickly and easily.