⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subscripting.hlp

📁 是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到
💻 HLP
字号:
{smcl}
{* 06apr2005}{...}
{cmd:help subscripting}
{hline}

{title:Title}

{pstd}
{hi:[U] 13.7 Explicit subscripting}


{title:Remarks}

{pstd}
Individual elements of variables and matrices may be referenced by
subscripting.  For help on matrix subscripting see {helpb matrix}.
Subscripting of {help variables} is discussed here.

{pstd}
Individual observations on variables can be referenced by subscripting the
variables.  Explicit subscripts are specified by following a variable name
with square brackets that contain an {help expression}.  The result of the
subscript expression is truncated to an integer, and the value of the variable
for the indicated observation is returned.  If the value of the subscript
expression is less than 1 or greater than _N (see {help _variables}), a
missing value is returned.

{pstd}For example:

{phang2}{cmd:. generate xlag = x[_n-1]}

{pstd}generates variable {cmd:xlag} containing the lagged value of {cmd:x}.
{cmd:_n} is understood by Stata to mean the observation number of the current
observation.  {cmd:_n-1} evaluates to the observation number of the previous
observation.  The first observation of {cmd:xlag} is missing since when
{cmd:_n} is 1, {cmd:x[_n-1]} refers to the nonexistent zeroth element of
{cmd:x}.  (See {help varlist} for discussion of time-series operators
which provide a more robust and convenient method of generating lags and leads
of a variable.)

{pstd}
The {helpb by} prefix command may be combined with {cmd:_n} to provide
subscripting within groups.

{pstd}For example:

{phang2}{cmd:. bysort pid (time): gen growth = (bp - bp[_n-1])/bp}

{pstd}generates the {cmd:growth} variable as the relative first difference in
{cmd:bp} for each {cmd:pid}.  The first observation of {cmd:growth} for each
{cmd:pid} will be missing since {cmd:_n} is interpreted relative to each
individual {cmd:pid}.


{title:Also see}

{psee}
Manual:  {bf:[U] 13.7 Explicit subscripting}

{psee}
Online:  {helpb by},
{help expression},
{helpb matrix},
{help _variables},
{help variables}
{p_end}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -