Stata 15 help for program

[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, then 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] sortpreserve.

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] fvexpand Expand factor varlists [P] macro Macro definition and manipulation [P] program Define and manipulate programs [P] return Return stored 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] levelsof Levels of variable [P] numlist Parse numeric lists [P] syntax Parse Stata syntax [P] tokenize Divide strings into tokens

Console output [P] dialog programming Dialog programming [P] display Display strings and values of scalar expressions [P] smcl Stata Markup and Control Language [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 [R] fvrevar Factor-variables operator programming command [P] mark Mark observations for inclusion [P] matrix Introduction to matrix commands [P] more Pause until key is pressed [P] nopreserve option nopreserve option [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 [M-2] class Object-oriented programming (classes) [P] class Class programming [P] class exit Exit class-member program and return result [P] classutil Class programming utility [P] estat programming Controlling estat after community-contributed 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 [M-5] moptimize() Model optimization [M-5] optimize() Function optimization [P] plugin Load a plugin [P] postfile Post results in Stata dataset [P] _predict Obtain predictions, residuals, etc., after estimation programming command [P] program properties Properties of user-defined programs [D] putmata Put Stata variables into Mata and vice versa [P] _return Preserve stored results [P] _rmcoll Remove collinear variables [P] _robust Robust variance estimates [P] serset Create and manipulate sersets [D] snapshot Save and restore data snapshots [P] unab Unabbreviate variable list [P] unabcmd Unabbreviate command name [P] varabbrev Control variable abbreviation [P] viewsource View source code

Special-interest programming commands [R] bstat Report bootstrap results [MV] cluster programming subroutines Add cluster-analysis routines [MV] cluster programming utilities Cluster-analysis programming utilities [R] fvrevar Factor-variables operator programming command [P] matrix dissimilarity Compute similarity or dissimilarity measures [MI] mi select Programmer's alternative to mi extract [ST] st_is Survival analysis subroutines for programmers [SVY] svymarkout Mark observations for exclusion on the basis of survey characteristics [MI] technical Details for programmers [TS] tsrevar Time-series operator programming command

File formats [P] file formats .dta Description of .dta file format

Mata [M] Mata Reference Manual


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index