Stata Programs

Programs are reusable functions.


Description

Programs are defined and manipulated using the -program- command.

To list all defined programs, try:

program dir

To examine a program, try:

program list foo


Usage

The following is the declaration of a simple program that takes two arguments.

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

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 2025-10-24 16:02:16 by DominicRicottone)