Differences between revisions 1 and 6 (spanning 5 versions)
Revision 1 as of 2023-01-13 21:56:41
Size: 294
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. 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.
Line 24: Line 46:
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 [[Stata/AdoFiles|ado files]].

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)