📄 mf_st_numscalar.hlp
字号:
{smcl}
{* 11feb2005}{...}
{cmd:help mata st_numscalar()}
{hline}
{* index stata scalars}{...}
{* index st_numscalar()}{...}
{* index st_strscalar()}{...}
{title:Title}
{p 4 28 2}
{bf:[M-5] st_numscalar() -- Obtain values from and put values into Stata scalars}
{title:Syntax}
{p 8 12 2}
{it:real}{bind: }
{cmd:st_numscalar(}{it:string scalar name}{cmd:)}
{p 8 12 2}
{it:void}{bind: }
{cmd:st_numscalar(}{it:string scalar name}{cmd:,}
{it:real value}{cmd:)}
{p 8 12 2}
{it:string}
{cmd:st_strscalar(}{it:string scalar name}{cmd:)}
{p 8 12 2}
{it:void}{bind: }
{cmd:st_strscalar(}{it:string scalar name}{cmd:,}
{it:string value}{cmd:)}
{p 4 8 2}
where
{p 8 12 2}
1. All functions allow {it:name} to be
{p_end}
{p 16 20 2}
a. global scalar such as {cmd:"myname"}
{p_end}
{p 16 20 2}
b. {cmd:r()} scalar such as {cmd:"r(mean)"}
{p_end}
{p 16 20 2}
c. {cmd:e()} scalar such as {cmd:"e(N)"}
{p_end}
{p 16 20 2}
d. {cmd:c()} scalar such as {cmd:"c(namelen)"}
{p 8 12 2}
{p 8 12 2}
2. {cmd:st_numscalar(}{it:name}{cmd:)} and
{cmd:st_strscalar(}{it:name}{cmd:)} return a 1 {it:x} 1
result containing the value of {it:name} or they return a 0 {it:x} 0 if
{it:name} does not exist.
{p 8 12 2}
3. {cmd:st_numscalar(}{it:name}{cmd:,} {it:value}{cmd:)} and
{cmd:st_strscalar(}{it:name}{cmd:,} {it:value}{cmd:)} allow
{it:value} to be
1 {it:x} 1 containing the new value with which {it:name} is to be created
or replaced, or 0 {it:x} 0, specifying that {it:name} is to be deleted.
{title:Description}
{p 4 4 2}
{cmd:st_numscalar(}{it:name}{cmd:)} returns the value of the specified
Stata numeric scalar, or it returns J(0,0,.) if the scalar does not exist.
{p 4 4 2}
{cmd:st_numscalar(}{it:name}{cmd:,} {it:value}{cmd:)} sets or resets the
value of the specified numeric scalar, assuming {it:value}!=J(0,0,.).
{cmd:st_numscalar(}{it:name}{cmd:,} {it:value}{cmd:)}
deletes the specified scalar if {it:value}==J(0,0,.).
{cmd:st_numscalar("x", J(0,0,.))} erases the scalar {cmd:x}, or it does
nothing if scalar {cmd:x} did not exist.
{p 4 4 2}
{cmd:st_strscalar(}{it:name}{cmd:)} returns the value of the specified
Stata string scalar, or it returns J(0,0,"") if the scalar does not exist.
{p 4 4 2}
{cmd:st_strscalar(}{it:name}{cmd:,} {it:value}{cmd:)} sets or resets the
value of the specified scalar, assuming {it:value}!=J(0,0,"").
{cmd:st_strscalar(}{it:name}{cmd:,} {it:value}{cmd:)}
deletes the specified scalar if {it:value}==J(0,0,"").
{cmd:st_strscalar("x", J(0,0,""))} erases the scalar {cmd:x}, or it does
nothing if scalar {cmd:x} did not exist.
{p 4 4 2}
Concerning deletion of a scalar, it does not matter whether you code
{cmd:st_numscalar(}{it:name}{cmd:, J(0,0,.))}
or
{cmd:st_strscalar(}{it:name}{cmd:, J(0,0,""))}; both yield the same result.
{title:Remarks}
{p 4 4 2}
See {bf:{help mf_st_global:[M-5] st_global()}}
and
{bf:{help mf_st_rclear:[M-5] st_rclear()}}.
{title:Conformability}
{p 4 4 2}
{cmd:st_numscalar(}{it:name}{cmd:)},
{cmd:st_strscalar(}{it:name}{cmd:)}:
{p_end}
{it:name}: 1 {it:x} 1
{it:result}: 1 {it:x} 1 or 0 {it:x} 0
{p 4 4 2}
{cmd:st_numscalar(}{it:name}{cmd:,} {it:value}{cmd:)},
{cmd:st_strscalar(}{it:name}{cmd:,} {it:value}{cmd:)}:
{p_end}
{it:name}: 1 {it:x} 1
{it:value}: 1 {it:x} 1 or 0 {it:x} 0
{it:result}: {it:void}
{title:Diagnostics}
{p 4 4 2}
{cmd:st_numscalar(}{it:name}{cmd:)} and
st_strscalar(}{it:name}{cmd:)}
return J(0,0,.) (J(0,0,"")) if Stata scalar
{it:name} does not exist. They abort with error, however, if
the name is malformed.
{p 4 4 2}
{cmd:st_numscalar(}{it:name}{cmd:,} {it:value}{cmd:)} and
{cmd:st_strscalar(}{it:name}{cmd:,} {it:value}{cmd:)} abort with error if
the name is malformed.
{title:Source code}
{p 4 4 2}
Functions are built-in.
{title:Also see}
{p 4 13 2}
Manual: {hi:[M-5] st_numscalar()}
{p 4 13 2}
Online: help for
{bf:{help mf_st_rclear:[M-5] st_rclear()}};
{bf:{help m4_stata:[M-4] stata}}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -