help program
-------------------------------------------------------------------------------
Title
[P] program -- Define and manipulate programs
Syntax
Define program
program [define] pgmname [, [ nclass | rclass | eclass | sclass ]
byable(recall[, noheader] | onecall) properties(namelist)
sortpreserve plugin]
List names of programs stored in memory
program dir
Eliminate program from memory
program drop { pgmname [pgmname [...]] | _all | _allado }
List contents of program
program list [ pgmname [pgmname [...]] | _all]
Description
program define defines and manipulates programs. define is required if
pgmname are any of the words: define, dir, drop, list, or plugin.
program dir lists the names of all the programs stored in memory.
program list lists the contents of the named program or programs.
program list _all lists the contents of all programs stored in memory.
program drop eliminates the named program or programs from memory.
program drop _all eliminates all programs stored in memory. program drop
_allado eliminates all programs stored in memory that were loaded from
ado-files. See [U] 17 Ado-files for an explanation of ado-files.
See [U] 18 Programming Stata for a description of programs.
See [P] trace for information on debugging programs.
Options
nclass states that the program being defined does not return results in
r(), e(), or s() and is the default.
rclass states that the program being defined returns results in r().
This is done using the return command; see [P] return. If the
program is not explicitly declared to be rclass, it may not change or
replace results in r().
eclass states that the program being defined returns results in e() or
modifies already existing results in e(). This is done using the
ereturn command; see [P] return and [P] ereturn. If the program is
not explicitly declared to be eclass, it may not directly replace or
change results in e()
sclass states that the program being defined returns results in s().
This is done using the sreturn command; see [P] return. If the
program is not explicitly declared to be sclass, then it may not
directly change or replace results in s(), but it still may clear s()
by using sreturn clear.
byable(recall[, noheader] | onecall) specifies that the program allow
Stata's by varlist: prefix. There are two styles for writing byable
programs: byable(recall) and byable(onecall). The writing of byable
programs is discussed in [P] byable.
properties(namelist) states that pgmname has the specified properties.
namelist may contain up to 80 characters, including separating
spaces. See [P] program properties.
sortpreserve states that the program changes the sort order of the data
and that Stata is to restore the original order when the program
concludes. See [P] byable and [P] sortpreserve for a discussion of
this important option.
plugin specifies that a plugin (a specially compiled C program) be
dynamically loaded and that the plugin define the new command; see
[P] plugin.
Useful commands for programmers
Basics
[U] 18 Programming Stata
[U] 18.3 Macros
[U] 18.11 Ado-files
[P] comments Add comments to programs
[P] macro Macro definition and manipulation
[P] return Return saved results
Program control
[U] 18.11.1 Version
[P] capture Capture return code
[P] continue Break out of loops
[P] error Display generic error message and
exit
[P] foreach Loop over items
[P] forvalues Loop over consecutive values
[P] if if programming command
[P] version Version control
[P] while Looping
Parsing and program arguments
[U] 18.4 Program arguments
[P] confirm Argument verification
[P] gettoken Low-level parsing
[P] numlist Parse numeric lists
[P] syntax Parse Stata syntax
[P] tokenize Divide strings into tokens
Console output
[P] dialog programming Dialog programming
[P] tabdisp Display tables
Commonly used programming commands
[P] byable Make programs byable
[P] #delimit Change delimiter
[P] exit Exit from a program or do-file
[P] mark Mark observations for inclusion
[P] matrix Matrix manipulation commands
[P] more Pause until key is pressed
[P] preserve Preserve and restore data
[P] quietly Quietly or noisily perform
command
[P] scalar Scalar variables
[P] smcl Stata Markup and Control Language
[P] sortpreserve Sort within programs
[P] timer Time sections of code by
recording and reporting time
spent
[TS] tsrevar Time-series operator programming
command
Debugging
[P] pause Program debugging command
[P] timer Time sections of code by
recording and reporting time
spent
[P] trace Debug Stata programs
Advanced programming commands
[P] automation Automation
[P] break Suppress Break key
[P] char Characteristics
[P] class Class programming
[P] class exit Exit class member
[P] classutil Exit class member program and
return result
[P] estat programming Controlling estat after
user-written commands
[P] _estimates Manage estimation result
[P] file Read and write ASCII text and
binary files
[P] findfile Find file in path
[P] include Include commands from file
[P] macro Macro definition and manipulation
[P] macro lists Manipulate lists
[R] ml Maximum likelihood estimation
[P] plugin Load a plugin
[P] postfile Save results in Stata dataset
[P] _predict Obtain predictions, residuals,
etc., after estimation
programming command
[P] program properties Properties of user-defined
programs
[P] _return Preserve saved results
[P] _rmcoll Remove collinear variables
[P] _robust Robust variance estimates
[P] serset Create and manipulate sersets
[P] unab Unabbreviate variable list
[P] unabcmd Unabbreviate command name
Special interest programming commands
[R] bstat Dialog programming
[MV] cluster programming subroutines Add cluster-analysis routines
[MV] cluster programming utilities Cluster-analysis programming
utilities
[ST] st_is Survival analysis subroutines for
programmers
[SVY] svymarkout Mark observations for exclusion
on the basis of survey
characteristics
[TS] tsrevar Time-series operator programming
command
File formats
[P] file formats .dta Description of .dta file format
Mata
[M] Mata Reference Manual
Also see
Manual: [P] program
Help: [U] 17 Ado-files, [P] discard, [D] clear