I was amazed at the VitalSource way of presenting the books....
Everything looks perfectly typeset, but yet you can "flip"
through the book in the same way you would "flip" through a very
long web page in your web browser. And best of all, whenever I
have my tablet with me, my books are just a swipe away.

Comment from the Stata technical group

Christopher F. Baum's An Introduction to Stata Programming, Second
Edition, is a great reference for anyone who wants to learn Stata
programming.

Baum assumes readers have some familiarity with Stata, but readers who
are new to programming will find the book accessible. He begins by
introducing programming concepts and basic tools. More advanced
programming tools such as structures and pointers and
likelihood-function evaluators using Mata are gradually introduced
throughout the book alongside examples.

This new edition reflects some of the most important statistical tools
added since Stata 10. Of note are factor variables and operators, the
computation of marginal effects, marginal means, and predictive
margins using margins, the use of gmm to implement
generalized method of moments estimation, and the use of suest
for seemingly unrelated estimation.

As in the previous edition of the book, Baum steps the reader through
the three levels of Stata programming. He starts with do-files.
Do-files are powerful batch files that support loops and conditional
statements and are ideal to automate your workflow as well as to
guarantee reproducibility of your work.

He then delves into ado-files, which are used to extend Stata by
creating new commands that share the syntax and behavior of official
commands. Baum gives an example of how to write a command to calculate
percentiles and the range of a variable, complete with documentation
and certification.

After introducing the fundamentals of command development, Baum shows
users how these concepts can be applied to help them write their own
custom estimation commands by using Stata's built-in numerical
maximum-likelihood estimation routine, ml, its built-in
nonlinear least-squares routines, nl and nlsur, and its
built-in generalized method of moments estimation routine.

Finally, he introduces Mata, Stata's matrix programming language.
Mata programs are integrated into ado-files to build a custom
estimation routine that is optimized for speed and numerical
stability. Baum briefly discusses how ado-file programming concepts
relate to Mata functions and objects. He also explains some of the
advantages of using Mata for certain programming tasks. Baum
introduces concepts by providing the background and importance of the
topic, presents common uses and examples, and then concludes with
larger, more applied examples he refers to as “cookbook recipes”.

Many of the examples are of particular interest because they arose
from frequently asked questions from Stata users. If you want to
understand basic Stata programming or want to write your own routines
and commands using advanced Stata tools, Baum's book is a great
reference.

About the author

Christopher F. Baum is a Professor of Economics and Social Work at Boston
College, where he codirects the undergraduate minor in scientific computation.
Baum has taught econometrics for many years, using Stata extensively. He has
over 40 years of experience with computer programming in a variety of languages
and has authored or coauthored several widely used Stata commands over the past
12 years. He is the author of An
Introduction to Modern Econometrics Using Stata, an associate editor of
the Stata Journal, and a
participant in many Stata Users Group
meetings in the United States and Europe.

4.1 Tabulating a logical condition across a set of variables
4.2 Computing summary statistics over groups
4.3 Computing the extreme values of a sequence
4.4 Computing the length of spells
4.5 Summarizing group characteristics over observations
4.6 Using global macros to set up your environment
4.7 List manipulation with extended macro functions
4.8 Using creturn values to document your work

6.7 Generating time-series data at a lower frequency
6.8 Using suest and gsem to compare estimates from nonoverlapping samples
6.9 Using reshape to produce forecasts from a VAR or VECM
6.10 Working with IRF files

7 Do-file programming: Prefixes, loops, and lists

7.1 Introduction

7.1.1 What you should learn from this chapter

7.2 Prefix commands

7.2.1 The by prefix
7.2.2 The statsby prefix
7.2.3 The xi prefix and factor-variable notation
7.2.4 The rolling prefix
7.2.5 The simulate and permute prefixes
7.2.6 The bootstrap and jackknife prefixes
7.2.7 Other prefix commands

11.2 The structure of a Stata program
11.3 The program statement
11.4 The syntax and return statements
11.5 Implementing program options
11.6 Including a subset of observations
11.7 Generalizing the command to handle multiple variables
11.8 Making commands byable

11.16.1 Presentation
11.16.2 Helpful Stata features
11.16.3 Respect for datasets
11.16.4 Speed and efficiency
11.16.5 Reminders
11.16.6 Style in the large
11.16.7 Use the best tools

12 Cookbook: Ado-file programming

12.1 Retrieving results from rolling
12.2 Generalization of egen function pct9010() to support all pairs of quantiles
12.3 Constructing a certification script
12.4 Using the ml command to estimate means and variances