Stata

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.

Working with GitHub and Stata

The problem and the solution Among the several ways available to load a program in Stata, the one that I like the most is to add the directory of my ado-file to the search path used by Stata, which is stored in the global macro S_ADO. This procedure is easily done by using the command adopath ++. I like this method because after I have modified and saved my ado-file, I only need to type discard and then run my code.

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.

Stata profile.do: nice tips

Each time you start a new Stata session, Stata looks for two files, sysprofile.do and profile.do. If these finds are found, Stata executes their contents. This post is about how to modity profile.do, in which you can put anything you want Stata to do before you start working with it. From time to time, I upload my profile.do into my GitHub repository (randrescastaneda/Stata_profile), so you can check it out and download it for your own purposes.

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.