Dear reader, first of all, thanks for stopping by, and showing interest in the Stata Guide! The Guide would not have been possible without the support and encouragement from the community. I have received countless messages, comments, suggestions, and feedback on various articles, all of which have tremendously helped in improving the content. I wanted to write this small article to explain the motivation behind all of this.

Why Stata?

In the field of micro econometrics, and economics in general, Stata is the go-to language. Having being involved in a dozens of projects in institutions like LUMS, the World Bank, DFID, USAID…

In this guide learn how to use syntax-based synchronization to GitHub directly from Stata using Git.

Why is this necessary? More and more projects are moving online and data sharing is now commonplace. In economics and other fields, having some online repository with data and code for replication is also becoming a norm. While some websites and journals provide their own platforms for data sharing, GitHub is now also slowly gaining traction as a hosting service. Furthermore, GitHub excels are two services that other online data sharing platforms lack: version control and the seamless ability to collaborate with code writing.

In this guide, we will learn how to import OpenStreetMap (OSM) data in Stata via QGIS. This allows us to make detailed choropleth maps from several spatial layers:

In this guide learn how to create your own Stata graph schemes. Additionally, this guide also releases a host of new schemes for your day-to-day Stata use:

The Stata Guide schemes:

Stata schemes are templates that define how graph are drawn. The scheme files are basically text files with a .scheme extension that can be modified and saved in your local directory for use. These text files are fairly extensive with well over 1700 options for fine tuning various graph elements including colors, backgrounds, sizes, legends, text etc.

Despite the flexibility of generating schemes, surprisingly little has been produced over the years. Some of…

This guide will present a series of graph replications for the Du Bois challenge in Stata. W. E. Du Bois was an American sociologist who played a pivotal role both in his research work on the black community in the USA, and creating unique visualizations during the early 1900s. At that point, there were no computers or reference guides, so the images were drawn using pens, rulers, compasses, and threads.

When the challenge was posted online, most people were replicating the figures in R or Tableau, or other dataviz-centered languages. My interest was to replicate the graphs in Stata. Du…

In this guide, learn how to make spirals and wrap text around them in Stata:

So why are we making spirals in Stata especially when they have a limited application? First, purely as a programming challenge in Stata. Second, this guide leads into some visualization replications like the DuBois challenge (#DuBoisChallenge on Twitter), and will be therefore referenced in later posts.

The guide also touches upon string functions for text formatting, and the use of modulus for generating the angles.


Like other guides, a basic knowledge of Stata is assumed. …

This guide covers one of the most under-documented features of Stata: regular expressions, or regex for short. In this guide we will learn how to implement the regex features shown in the Stata cheat sheet below. This includes learning about quantifiers, building specific to generic expressions from bottom-up, word boundaries, and learning about greedy versus possessive matching:

Printable PDF version:

Regex is the core algorithm that is used for searching through text using pattern matching. One comes across online regex implementations almost daily. These include auto checking whether you have filled your email address correctly, or whether your password has sufficient characters or…

In this guide learn to program pie charts from scratch in Stata:

This is a fairly long guide. But it lays the foundation for dealing pies and arcs and their area fills in Stata. This allows for creating and customizing a whole range of visualizations, for example, donut charts, sunburst graphs, pies with different radii, or even half pies. These are all topics for subsequent guides. This guide is fairly advanced and discusses several programming elements. These include cartesian to polar coordinate transformation, matrix rotations, using nested if-else conditions, reshape sorting variables, and customizing color schemes.

Why is this necessary…

Last updated: 04 March 2021

In this guide learn how to export Stata tables and regressions to LaTeX to generate customized tables.

Asjad Naqvi

Here you will find information on Stata, COVID-19, and data visualizations.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store