Stata 15 help for language

Title

[U] 11 Language syntax

Syntax

With few exceptions, the basic language syntax is

[prefix :] command [varlist] [=exp] [if] [in] [weight] [using filename] [, options]

see language element description ------------------------------------------------------------------------- help prefix prefix : prefix command help command command Stata command help varlist varlist variable list help exp =exp expression help if if if exp qualifier help in in in range qualifier help weight weight weight help using using filename using filename modifier help options options options -------------------------------------------------------------------------

Description

Stata commands follow a common syntax. A command's syntax diagram shows how to type the command, indicates possible options, and gives the minimum allowed abbreviations for items in the command.

Remarks

In a syntax diagram, square brackets distinguish optional from required options. Items presented like this should be typed exactly as they appear in the diagram. Underlining is used to indicate the shortest abbreviations where abbreviations are allowed, so that an item presented like this indicates that this may be abbreviated to th. Items presented like this represent arguments for which you are to substitute variable names, observation numbers, and the like.

Options, denoted as options in the generic syntax diagram above, are specified at the end of the command. A comma must precede the first option.

Some options take numeric lists as arguments. See help numlist for details on various ways of specifying these numeric lists.

Some commands also have an immediate form (allow you to enter numbers directly instead of entering variable names). See help immed for details.

Programmers interested in incorporating Stata's language features into their Stata programs should see help syntax for the syntax command.

Examples

count command

The count command has the following syntax diagram:

count [if] [in]

count is the command and it may be abbreviated to cou. The if and in qualifiers are optional; see help if and help in.

Examples:

. sysuse auto . count if rep78 > 4 . count if weight < 3000 . cou if rep78 > 4 & weight < 3000

replace command

The replace command has the following syntax diagram:

replace oldvar =exp [if] [in] [, nopromote ]

replace is the command. oldvar corresponds to varlist in the generic syntax diagram. Here oldvar is required because there are no square brackets around it. The equal sign followed by an expression is also required. The if and in qualifiers are optional. There is one option, nopromote, which may be abbreviated to nop. If this option is specified, it must follow a comma after the earlier parts of the command have been typed.

Examples:

. sysuse nlsw88 . replace married = 2 if never_married == 0 & married == 0 . replace wage = wage * 2080 . replace age = age^2, nopromote


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index