📄 _variables.hlp
字号:
{smcl}
{* 06apr2005}{...}
{cmd:help _variables}
{hline}
{title:Title}
{pstd}
{hi:[U] 13.4 System variables (_variables)}
{title:Description}
{pstd}
Expressions may also contain {it:_variables} (pronounced "underscore
variables"). These are built in system variables that are created and updated
by Stata. They are called {it:_variables} because their names all begin with
the underscore '_' character.
{pstd}
The {it:_variables} are
{phang}{cmd:[}{it:eqno}{cmd:]_b[}{it:varname}{cmd:]} (synonym:
{cmd:[}{it:eqno}{cmd:]_coef[}{it:varname}{cmd:]}) contains the value (to
machine precision) of the coefficient on {it:varname} from the most recently
fitted model (such as ANOVA, regression, Cox, logit, probit, multinomial
logit, and the like). See
{hi:[U] 13.5 Accessing coefficients and standard errors} for a complete
description.
{phang}{cmd:_cons} is always equal to the number 1 when used directly and
refers to the intercept term when used indirectly, as in {cmd:_b[_cons]}.
{phang}{cmd:_n} contains the number of the current observation.
{phang}{cmd:_N} contains the total number of observations in the dataset.
{phang}{cmd:_pi} contains the value of pi to machine precision.
{phang}{cmd:_rc} contains the value of the return code from the most recent
{cmd:capture} command; see {helpb capture}.
{phang}{cmd:[}{it:eqno}{cmd:]_se[}{it:varname}{cmd:]} contains the value (to
machine precision) of the standard error of the coefficient on {it:varname}
from the most recently fitted model (such as ANOVA, regression, Cox, logit,
probit, multinomial logit, and the like). See
{hi:[U] 13.5 Accessing coefficients and standard errors} for a complete
description.
{pstd}
The {cmd:_n} and {cmd:_N} variables are useful for indexing observations or
generating sequences of numbers. {cmd:_n} can act as a running counter within
a by group and {cmd:_N} acts as the total number within each by group.
{pstd}
{cmd:_rc} is useful for programmers, particularly if you want to test a
command internal to a program without having the program terminate.
{title:Examples}
{phang}{cmd:. by famid: gen sibs = _N}{p_end}
{phang}{cmd:. by famid: gen birtho = _N - _n + 1}{p_end}
{phang}{cmd:. display _pi}{p_end}
{phang}{cmd:. display cos(_pi)}{p_end}
{phang}{cmd:. gen x = cos(_pi/4*_n)}{p_end}
{phang}{cmd:. gen price2 = price[_n-1]}
{phang}{cmd:. mvreg len disp gear_ratio = turn tru mpg wei}{p_end}
{phang}{cmd:. display [displ]_b[mpg]}
{phang}{cmd:. mlogit rep gear_ratio turn tru}{p_end}
{phang}{cmd:. display [5]_b[turn]}
{title:Also see}
{psee}
Manual: {bf:[U] 13.4 System variables (_variables)}
{psee}
Online: {helpb by},
{helpb generate},
{helpb replace},
{help subscripting}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -