Differences between revisions 2 and 3
Revision 2 as of 2023-01-13 22:01:32
Size: 721
Comment:
Revision 3 as of 2023-06-08 00:38:36
Size: 811
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

Reusable functions can be defined in the Stata programming language as '''programs'''.

Stata Programs

Reusable functions can be defined in the Stata programming language as programs.


Definition

Stata programs are defined using the program command.

program foo
  args a b
  if "`b'"=="" {
    di "Expected 2 arguments (got 1)"
    exit
  }
  gen `a'=`b'
end


Usage

To list all defined programs, try:

program dir

To examine a program, try:

program list foo

Use program list _all to list the contents of all programs.

To delete a program, try:

program drop foo

Use program drop _all to delete all programs and program drop _allado to delete all programs that were loaded from ado files.


CategoryRicottone

Stata/Programs (last edited 2023-06-09 12:51:35 by DominicRicottone)