📄 extended_fcn.hlp
字号:
{smcl}
{* 14feb2005}{...}
{cmd:help extended_fcn}
{hline}
{title:Title}
{p2colset 5 18 20 2}{...}
{p2col :{hi:[P] macro} {hline 2}}Extended macro functions{p_end}
{p2colreset}{...}
{title:Syntax}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:all} {c -(}{cmd:globals}|{cmd:scalars}|{cmd:matrices}{c )-}
[{cmd:"}{it:pattern}{cmd:"}]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:all} {c -(}{cmd:numeric}|{cmd:string}{c )-} {cmd:scalars}
[{cmd:"}{it:pattern}{cmd:"}]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:char} {c -(} {it:varname}{cmd:[]} |
{it:varname}{cmd:[}{it:charname}{cmd:]} {c )-}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:char} {c -(} {cmd:_dta[]} | {cmd:_dta[}{it:charname}{cmd:]} {c )-}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:cole:q} {space 6} {it:matrixname} [{cmd:,} {cmdab:q:uoted} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:colf:ullnames} {it:matrixname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:coln:ames} {space 3} {it:matrixname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:constraint} {c -(} {cmd:dir} | {it:#} {c )-}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:data} {cmdab:l:abel}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:dir} [{cmd:"}]{it:dirname}[{cmd:"}]
{c -(}{cmdab:file:s}|{cmdab:dir:s}|{cmd:other}{c )-}
[{cmd:"}]{it:pattern}[{cmd:"}]
[{cmd:,} {cmd:nofail} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:di:splay} {it:{help display:display_directive}}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:e(scalars} | {cmd:macros} | {cmd:matrices} | {cmd:functions)}{p_end}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:env:ironment} {it:name}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:f:ormat} {it:varname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:lab:el} {c -(} {it:valuelabelname} |
{cmd:(}{it:varname}{cmd:)} {c )-}
{c -(} {cmd:maxlength} | {it:#} [{it:#}] {c )-}
[{cmd:,} {cmd:strict} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:length} {c -(} {cmdab:loc:al} | {cmdab:gl:obal} {c )-} {it:macname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:list} {it:{help macrolists:macrolist_directive}}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:permname} {it:suggestedname}
[{cmd:,} {cmdab:l:ength:(}{it:#}{cmd:)} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:piece} {it:#piece_number} {it:#length_of_pieces} {cmd:of}
[{cmd:`}]{cmd:"}{it:string}{cmd:"}[{cmd:'}]
[{cmd:,} {cmdab:nob:reak} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:properties} {it:pgmname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:r(scalars} | {cmd:macros} | {cmd:matrices} | {cmd:functions)}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:rowe:q} {space 6} {it:matrixname} [{cmd:,} {cmdab:q:uoted} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:rowf:ullnames} {it:matrixname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:rown:ames} {space 3} {it:matrixname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:s(macros)}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:sort:edby}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:subinstr} {c -(} {cmdab:loc:al} | {cmdab:gl:obal} {c )-}
{it:macname} [{cmd:`}]{cmd:"}{it:<from>}{cmd:"}[{cmd:'}]
[{cmd:`}]{cmd:"}{it:<to>}{cmd:"}[{cmd:'}]
[{cmd:,} {cmd:all} {cmdab:w:ord}
{cmdab:c:ount:(}{c -(} {cmdab:loc:al} | {cmdab:gl:obal} {c )-}
{it:macname}{cmd:)} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:sysdir} [ {cmd:STATA} | {cmd:UPDATES} | {cmd:BASE} | {cmd:SITE} |
{cmd:PLUS} | {cmd:PERSONAL} | {it:dirname} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:tempv:ar}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:tempf:ile}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:tsnorm} {it:string} [{cmd:,} {cmdab:v:arname} ]
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:t:ype} {it:varname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:val:ue} {cmdab:l:abel} {it:varname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmdab:var:iable} {cmdab:l:abel} {it:varname}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:word count} {it:string}{p_end}
{p 4 36 2}
{c -(}{cmdab:loc:al} | {cmdab:gl:obal}{c )-}
{it:macname} {cmd::}
{cmd:word} {it:#} {cmd:of} {it:string}
{title:Description}
{p 4 8 2}
{cmd:all} {c -(} {cmd:globals} | {cmd:scalars} | {cmd:matrices} {c )-}
[{cmd:"}{it:pattern}{cmd:"}]
{break}
puts in {it:macroname} the specified globals, scalars, or matrices that match
the {it:pattern}, where the pattern matching is defined by Stata's
{cmd:strmatch(}{it:s1}{cmd:,}{it:s2}{cmd:)} function.
{p 4 8 2}
{cmd:all} {c -(} {cmd:numeric} | {cmd:string} {c )-} {cmd:scalars}
[{cmd:"}{it:pattern}{cmd:"}]
{break}
puts in {it:macroname} the specified numeric or string scalars that match the
{it:pattern}, where the pattern matching is defined by Stata's
{cmd:strmatch(}{it:s1}{cmd:,}{it:s2}{cmd:)} function.
{p 4 8 2}
{cmd:char} {c -(} {it:varname}{cmd:[]} |
{it:varname}{cmd:[}{it:charname}{cmd:]} {c )-}{p_end}
{p 4 8 2}
{cmd:char} {c -(} {cmd:_dta[]} | {cmd:_dta[}{it:charname}{cmd:]} {c )-}
{break}
return information on the characteristics of a dataset; see {helpb char}.
{p 4 8 2}
{cmd:coleq} {space 6} {it:matrixname} [{cmd:,} {cmd:quoted} ]{p_end}
{p 4 8 2}
{cmd:colfullnames} {it:matrixname}{p_end}
{p 4 8 2}
{cmd:colnames} {space 3} {it:matrixname}
{break}
return lists of matrix column names; see {help matmacfunc}.
{p 4 8 2}
{cmd:constraint} {c -(} {cmd:dir} | {it:#} {c )-}
{break}
gives information on constraints. {cmd:constraint} {it:#} puts constraint
{it:#} in {it:macroname,} or returns "" if constraint is not defined.
{cmd:constraint dir} returns an unsorted numerical list of those constraints
that are currently defined.
{p 4 8 2}
{cmd:data label}
{break}
returns the dataset label; see {helpb label}.
{p 4 8 2}
{cmd:dir} [{cmd:"}]{it:dirname}[{cmd:"}]
{c -(} {cmd:files} | {cmd:dirs} | {cmd:other} {c )-}
[{cmd:"}]{it:pattern}[{cmd:"}] [{cmd:,} {cmd:nofail} ]
{break}
puts in {it:macroname} the specified files, directories, or entries that are
neither files nor directories, from directory {it:dir} and matching pattern
{it:pattern}, where the pattern matching is defined by Stata's
{cmd:match(}{it:s1}{cmd:,}{it:s2}{cmd:)} function.
{p 8 12 2}
{cmd:nofail} specifies that if the directory contains too many filenames to
fit into a macro, the filenames that fit should be returned rather than an
error issued.
{p 4 8 2}
{cmd:display} {it:display_directive}
{break}
fills in {it:macroname} with the {it:{help display:display_directive}}. This
is Stata's {cmd:display} command with its output redirected to a macro.
{cmd:display} used in this way does not allow {cmd:in} {it:color},
{cmd:_newline}, {cmd:_continue}, or {cmd:_request(}{it:macroname}{cmd:)}.
{p 4 8 2}
{cmd:e(scalars} | {cmd:macros} | {cmd:matrices} | {cmd:functions)}
{break}
returns the names of all the saved results in {cmd:e()} of the specified type.
{p 4 8 2}
{cmd:environment} {it:name}
{break}
allowed under Unix or Windows, imports the contents of the Unix or Windows
environment variable {it:name} into the Stata macro.
{p 4 8 2}
{cmd:format} {it:varname}
{break}
returns the display format associated with {it:varname}.
{p 4 8 2}
{cmd:label} {c -(} {it:valuelabelname} | {cmd:(}{it:varname}{cmd:)} {c )-}
{c -(} {cmd:maxlength} | {it:#} [{it:#}] {c )-}
[{cmd:,} {cmd:strict} ]
{break}
looks up {it:#} in {it:valuelabelname} and returns the label value of {it:#}
if {it:valuelabelname} exists and {it:#} is recorded in it, returns {it:#}
otherwise. If a second number is specified, the result is trimmed to being no
more than that many characters in length.
{p 8 8 2}
If {cmd:(}{it:varname}{cmd:)} (note parentheses) is specified rather than
{it:valuelabelname}, the logic is the same except that the value label for the
variable {it:varname}, if any, is used.
{p 8 8 2}
{cmd:maxlength} specifies that, rather than looking up a number in a value
label, {cmd:label} is to return the maximum length of the labels themselves.
For instance, if value label {cmd:yesno} mapped 0 to {cmd:no} and 1 to
{cmd:yes}, then its {cmd:maxlength} would be 3 because {cmd:yes} is the
longest label and it has three characters.
{p 8 8 2}
{cmd:strict} specifies that nothing is to be returned if there is no value
label for {it:#}.
{p 4 8 2}
{cmd:length} {c -(} {cmdab:loc:al} | {cmdab:gl:obal} {c )-} {it:macname}
{break}
returns the length (in number of characters) of {it:macname}, or 0 if
{it:macname} is undefined.
{p 4 8 2}
{cmd:list} {it:macrolist_directive}
{break}
fills in {it:macroname} with the {it:{help macrolists:macrolist_directive}},
which specifies one of many available commands or operators for working with
macros that contain lists; see {help macrolists}.
{p 4 8 2}
{cmd:permname} {it:suggestedname} [{cmd:,} {cmd:length(}{it:#}{cmd:)} ]
{break}
returns a valid new variable name based on {it:suggestedname}, where
{it:suggestedname} must follow naming conventions, but may be either too long
or correspond to an already existing variable.
{p 8 12 2}
{cmd:length(}{it:#}{cmd:)} specifies the maximum length of the returned
variable name, 32 by default.
{p 4 8 2}
{cmd:properties} {it:pgmname}
{break}
returns the properties declared for program {it:pgmname}; see
{helpb program}.
{p 4 8 2}
{cmd:piece} {it:#piece_number} {it:#length_of_pieces} {cmd:of}
[{cmd:`}]{cmd:"}{it:string}{cmd:"}[{cmd:'}] [{cmd:,} {cmd:nobreak} ]
{break}
returns a piece of {it:string}. This function provides a smart method of
breaking a string into pieces of roughly the specified length.
{it:#piece_number} specifies which piece to obtain. {it:#length_of_pieces}
specifies the maximum length of each piece. When a word is longer than
{it:#length_of_pieces}, the word will be split unless {cmd:nobreak} is
specified. {cmd:nobreak} specifies that words are not to be broken even if
that would result in a string longer than {it:#length_of_pieces} characters.
{p 4 8 2}
{cmd:r(scalars} | {cmd:macros} | {cmd:matrices} | {cmd:functions)}
{break}
returns the names of all the saved results in {hi:r()} of specified type.
{p 4 8 2}
{cmd:roweq} {space 6} {it:matrixname} [{cmd:,} {cmd:quoted} ]{p_end}
{p 4 8 2}
{cmd:rowfullnames} {it:matrixname}{p_end}
{p 4 8 2}
{cmd:rownames} {space 3} {it:matrixname}
{break}
return lists of matrix row names; see {help matmacfunc}.
{p 4 8 2}
{cmd:s(macros)}
{break}
returns the names of all the saved results in {hi:s()} of type macro (which is
the only type that exists within {hi:s()}).
{p 4 8 2}
{cmd:sortedby}
{break}
fills in the {it:macroname} with the list of variables by which the data are
sorted, or leaves the macro undefined if the dataset is not sorted.
{p 4 8 2}
{cmd:subinstr} {c -(} {cmdab:loc:al} | {cmdab:gl:obal} {c )-} {it:macname}
[{cmd:`}]{cmd:"}{it:<from>}{cmd:"}[{cmd:'}]
[{cmd:`}]{cmd:"}{it:<to>}{cmd:"}[{cmd:'}]
[{cmd:,} {cmd:all} {cmd:word}
{cmd:count(}{c -(} {cmd:local} | {cmd:global} {c )-}
{it:macname}{cmd:)} ]
{break}
changes the first occurrence of {cmd:"}{it:<from>}{cmd:"} to
{cmd:"}{it:<to>}{cmd:"} in {it:macroname}.
{p 8 12 2}
{cmd:all} specifies that all occurrences are to be changed.
{p 8 12 2}
{cmd:word} specifies that substitutions are allowed only on space-separated
tokens (words). In this case, tokens at the beginning or end also count as
being space separated.
{p 8 12 2}
{cmd:count()} places the number of substitutions that occur into the named
macro.
{p 4 8 2}
{cmd:sysdir} [ {cmd:STATA} | {cmd:UPDATES} | {cmd:BASE} | {cmd:SITE} |
{cmd:PLUS} | {cmd:PERSONAL} | {it:dirname} ]
{break}
returns the various Stata system directory path names; see {helpb sysdir}.
{p 4 8 2}
{cmd:tempvar}
{break}
returns a name that can be used as a temporary variable.
{p 4 8 2}
{cmd:tempfile}
{break}
returns a name that can be used as a temporary file.
{p 4 8 2}
{cmd:tsnorm} {it:string} [{cmd:,} {cmd:varname} ]
{break}
returns the canonical form of {it:string} when {it:string} is interpreted as a
time-series operator. For instance, if {it:string} is {cmd:ldl}, "{cmd:L2D}"
is returned, and if {it:string} is {cmd:l.ldl}, "{cmd:L3D}" is returned. If
{it:string} is nothing, "" is returned.
{p 8 8 2}
{cmd:tsnorm} with the {cmd:varname} option returns the canonical form when
{it:string} is interpreted as a time-series operated variable. For instance,
if {it:string} is {cmd:ldl.gnp}, "{cmd:L2D.gnp}" is returned, and if
{it:string} is {cmd:l.ldl.gnp}, "{cmd:L3D.gnp}" is returned. If {it:string}
is just a variable name, the variable name is returned.
{p 4 8 2}
{cmd:type} {it:varname}
{break}
returns the storage type for {it:varname}.
{p 4 8 2}
{cmd:value label} {it:varname}
{break}
returns the name of the value label associated with the variable.
{p 4 8 2}
{cmd:variable label} {it:varname}
{break}
returns the variable label associated with the variable.
{p 4 8 2}
{cmd:word count} {it:string}
{break}
returns the number of words in the string.
{p 4 8 2}
{cmd:word} {it:#} {cmd:of} {it:string}
{break}
returns the {it:#}th word of {it:string}.
{title:Also see}
{psee}
Manual: {bf:[P] macro}
{psee}
Online: {helpb char}, {helpb gettoken},
{help macrolists}, {helpb matrix},
{helpb preserve}, {help quotes}, {helpb return},
{helpb scalar}, {helpb syntax}, {helpb tokenize}
{p_end}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -