Differences between revisions 5 and 6
Revision 5 as of 2023-06-09 12:51:35
Size: 794
Comment:
Revision 6 as of 2025-10-24 16:02:16
Size: 799
Comment: Rewrite
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
In the Stata programming language, a '''program''' is a reusable functions. '''Programs''' are reusable functions.
Line 11: Line 11:
== Definition == == Description ==
Line 13: Line 13:
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 ==
Programs are defined and manipulated using the '''`-program-`''' command.
Line 44: Line 27:
Use `program list _all` to list the contents of all programs. ----



== 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
}}}

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)