📄 mf_st_varindex.hlp
字号:
{smcl}
{* 17mar2005}{...}
{cmd:help mata st_varindex()}
{hline}
{* index st_varindex()}{...}
{* index _st_varindex()}{...}
{title:Title}
{p 4 4 2}
{bf:[M-5] st_varindex() -- Obtain variable indices from variable names}
{title:Syntax}
{p 8 12 2}
{it:real rowvector}{bind: }
{cmd:st_varindex(}{it:string rowvector s}{cmd:)}
{p 8 12 2}
{it:real rowvector}{bind: }
{cmd:st_varindex(}{it:string rowvector s}{cmd:,}
{it:real scalar abbrev}{cmd:)}
{p 8 12 2}
{it:real rowvector}
{cmd:_st_varindex(}{it:string rowvector s}{cmd:)}
{p 8 12 2}
{it:real rowvector}
{cmd:_st_varindex(}{it:string rowvector s}{cmd:,}
{it:real scalar abbrev}{cmd:)}
{title:Description}
{p 4 4 2}
{cmd:st_varindex(}{it:s}{cmd:)} returns the variable index associated with
each variable name recorded in {it:s}. {cmd:st_varindex(}{it:s}{cmd:)} does
not allow variable-name abbreviations such as "pr" for "price".
{p 4 4 2}
{cmd:st_varindex(}{it:s}{cmd:,} {it:abbrev}{cmd:)} does the same thing, but
allows you to specify whether variable-name abbreviations are to be allowed.
Abbreviations are allowed if {it:abbrev}!=0.
{cmd:st_varindex(}{it:s}{cmd:)} is equivalent to
{cmd:st_varindex(}{it:s}{cmd:,} {cmd:0)}.
{p 4 4 2}
{cmd:_st_varindex()} does the same thing as
{cmd:st_varindex()}.
The two functions differ in how they respond when a name is not found.
{cmd:st_varindex()} aborts with error, and
{cmd:_st_varindex()} places missing in the appropriate element of the
returned result.
{title:Remarks}
{p 4 4 2}
These functions require each element of {it:s} contain a variable name,
such as
{it:s} = ("price", "mpg", "weight")
{p 4 4 2}
If you have a single string containing multiple names
{it:s} = ("price mpg weight")
{p 4 4 2}
then use {cmd:tokens()} to split it into the desired form, as in
{it:k} {cmd:=} {cmd:st_varindex(tokens(}{it:s}{cmd:))}
{p 4 4 2}
See {bf:{help mf_tokens:[M-5] tokens()}}.
{title:Conformability}
{p 4 4 2}
{cmd:st_varindex(}{it:s}{cmd:,} {it:abbrev}{cmd:)},
{cmd:_st_varindex(}{it:s}{cmd:,} {it:abbrev}{cmd:)}:
{p_end}
{it:s}: 1 {it:x k}
{it:abbrev}: 1 {it:x} 1
{it:result}: 1 {it:x k}
{title:Diagnostics}
{p 4 4 2}
{cmd:st_varindex()} aborts with error if any name is not found.
{p 4 4 2}
{cmd:_st_varindex()} puts missing in the appropriate element of the
returned result for any name that is not found.
{title:Source code}
{p 4 4 2}
Functions are built-in.
{title:Also see}
{p 4 13 2}
Manual: {hi:[M-5] st_varindex()}
{p 4 13 2}
Online: help for
{bf:{help mf_st_varname:[M-5] st_varname()}},
{bf:{help mf_tokens:[M-5] tokens()}};
{bf:{help m4_stata:[M-4] stata}}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -