This work focuses on three types of Stata programming: do-file programming, ado-file programming, and Mata functions that work in conjunction with do- and ado-files. It explains how to usefully automate work with Stata and how to use Stata more effectively through programming on one or more of these levels. After presenting elementary concepts of the command-line interface and commonly used tools for working with programs and data sets, the text follows a unique format by offering cookbook chapters after each main chapter. These cookbook chapters look at how to perform a specific programming task with Stata and provide a complete solution to the problem. The text also includes numerous examples of Mata, Stata’s matrix programming language.