Stata Coding Practices
This page list a lot of resources both developed at DIME but also by other people or organizations.
At DIME we have developed a package of Stata commands specially developed for impact evaluations but could also be useful in other contexts as well. The package is called ietoolkit and can be installed from the SSC server. To install the package, type
ssc install ietoolkit in your Stata command window.
Please visit our github page for details: https://github.com/worldbank/ietoolkit
ietoolkit provides a set of commands that address different aspects of data management and data analysis in relation to Impact Evaluations. These include the following:
- iebaltab is a tool for running balance test regressions and output the result in well formatted balance tables
- ieddtab is a tool for running difference in difference regressions and output the result in well formatted tables
- ieboilstart standardizes the boilerplate code at the top of all do-files
- ieduplicates and iecompdup are useful tools to identify and correct for duplicates, particularly in primary survey data
- iefolder sets up project folders and creates master do-files that links to all sub-folders
- iegitaddmd adds a placeholder file to empty folders so that folder structures with empty folders can be shared on GitHub
- iegraph produces graphs of estimation results in common impact evaluation regression models
- iematch is an algorithm for matching observations in one group to "the most similar" observations in another group
- iedropone drops observations and controls that the correct number was dropped
- ieboilsave performs checks before saving a data set
At DIME we have also developed a package of Stata commands specially developed for primary data collection . The package is called iefieldkit and can be installed from the SSC server (as of Feb 2019). To install the package, type
ssc install fieldkit in your Stata command window.
Please visit our github page for details: https://github.com/worldbank/iefieldkit
fieldkit provides a set of commands that address different aspects of primary data collection. These include the following:
- iecodebook is a tool for applying bulk changes data sets and combining data sets from slightly different data collections.
- ietestform is a tool for testing for SurveyCTO forms for typos, usage of best practices etc.
Stata Command Repository
Repository with a large number of Stata ado files. These commands cannot be installed through SSC but click the link for installation instructions. This repository contains a broad variety of Stata commands (adofiles) which are useful in data management, statistical analysis, and the production of graphics. In many cases, these adofiles reduce the production of routine items from a tedious programming task to a single command line – such as data import and cleaning; production of summary statistics tables; and categorical bar charts with confidence intervals.
DIME's Stata IE Visual Library
We have developed a repository where we collect Stata Graph examples on GitHub. Feel free to submit your own example codes there.
Snippets of Code with Best Practices with Explanations
The following code examples have been written in a way that it they should be easy to experiment with and be possible to build on to fit many different contexts. Download the files and read the instructions.
- Intro to how to write programs (also called commands or functions) in Stata
- Share functions (sub-programs) between command in the same package