Differences between revisions 2 and 6 (spanning 4 versions)
Revision 2 as of 2023-01-13 22:01:32
Size: 721
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 2: Line 2:

'''Programs''' are reusable functions.
Line 9: Line 11:
== Definition == == Description ==
Line 11: Line 13:
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 ==
Programs are defined and manipulated using the '''`-program-`''' command.
Line 42: 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)