Programming Reference Manual

This manual includes features that are part of StataNow.

Publisher: Stata Press
Copyright: 2023
ISBN-13: 978-1-59718-393-2
Pages: 647
Suggested citation

StataCorp. 2023. Stata 18 Programming Reference Manual. College Station, TX: Stata Press.

Supplemental materials

Table of contents
Intro Introduction to programming manual

Automation Automation

break Suppress Break key
byable Make programs byable

capture Capture return code
char Characteristics
class Class programming
class exit Exit class-member program and return result
classutil Class programming utility
comments Add comments to programs
confirm Argument verification
continue Break out of loops
creturn Return c-class values

_datasignature Determine whether data have changed
#delimit Change delimiter
Dialog programming Dialog programming
discard Drop automatically loaded programs
display Display strings and values of scalar expressions

ereturn Post the estimation results
error Display generic error message and exit
estat programming Controlling estat after community-contributed commands
_estimates Manage estimation results
Estimation command How to program an estimation command
exit Exit from a program or do-file

file Read and write text and binary files
File formats .dta Description of .dta file format
File formats .dtas Description of Stata frameset (.dtas) file format
findfile Find file in path
foreach Loop over items
forvalues Loop over consecutive values
frame post Post results to dataset in another frame
fvexpand Expand factor varlists

gettoken Low-level parsing

H2O intro Introduction to integration with H2O

if if programming command
include Include commands from file

Java intro Introduction to Java plugins
Java integration Java integration for Stata
Java plugin Introduction to Java plugins
Java utilities Java utilities
javacall Call a Java plugin

levelsof Distinct levels of a variable

macro Macro definition and manipulation
macro lists Manipulate lists
makecns Constrained estimation
mark Mark observations for inclusion
matlist Display a matrix and control its format
matrix Introduction to matrix commands
matrix accum Form cross-product matrices
matrix define Matrix definition, operators, and functions
matrix dissimilarity Compute similarity or dissimilarity measures
matrix eigenvalues Eigenvalues of nonsymmetric matrices
matrix get Access system matrices
matrix mkmat Convert variables to matrix and vice versa
matrix rowjoinbyname Join rows while matching on column names
matrix rownames Name rows and columns
matrix score Score data from coefficient vectors
matrix svd Singular value decomposition
matrix symeigen Eigenvalues and eigenvectors of symmetric matrices
matrix utility List, rename, and drop matrices
more Pause until key is pressed

nopreserve option nopreserve option
numlist Parse numeric lists

pause Program debugging command
plugin Load a plugin
postfile Post results in Stata dataset
_predict Obtain predictions, residuals, etc., after estimation programming command
preserve Preserve and restore data
program Define and manipulate programs
program properties Properties of user-defined programs
Project Manager Organize Stata files
PyStata intro Introduction to using Python and Stata together
PyStata integration Call Python from Stata StataNow
PyStata module Python package pystata to call Stata from Python StataNow

quietly Quietly and noisily perform Stata command

_return Preserve stored results
return Return stored results
_rmcoll Remove collinear variables
rmsg Return messages
_robust Robust variance estimates

scalar Scalar variables
serset Create and manipulate sersets
set locale_functions Specify default locale for functions
set locale_ui Specify a localization package for the user interface
set sortmethod Specify a sort method
set sortrngstate Set the state of sort’s randomizer
signestimationsample Determine whether the estimation sample has changed
sleep Pause for a specified time
smcl Stata Markup and Control Language
sortpreserve Sort within programs
syntax Parse Stata syntax
sysdir Query and set system directories

tabdisp Display tables
timer Time sections of code by recording and reporting time spent
tokenize Divide strings into tokens
trace Debug Stata programs

unab Unabbreviate variable list
unabcmd Unabbreviate command name

varabbrev Control variable abbreviation
version Version control
viewsource View source code

while Looping
window programming Programming menus and windows
window fopen Display open/save dialog box
window manage Manage window characteristics
window menu Create menus
window push Copy command into History window
window stopbox Display message box


Combined author index
Combined subject index