help unab, help tsunab, help fvunab
-------------------------------------------------------------------------------
Title
[P] unab -- Unabbreviate variable list
Syntax
Expand and unabbreviate standard variable lists
unab lmacname : [varlist] [, min(#) max(#) name(string)]
Expand and unabbreviate variable lists that may contain time-series
operators
tsunab lmacname : [varlist] [, min(#) max(#) name(string)]
Expand and unabbreviate variable lists that may contain time-series
operators or factor variables
fvunab lmacname : [varlist] [, min(#) max(#) name(string)]
Description
unab expands and unabbreviates a varlist of existing variables, placing
the results in the local macro lmacname. unab is a low-level parsing
command. The syntax command is a high-level parsing command that, among
other things, also unabbreviates variable lists; see [P] syntax.
The difference between unab and tsunab is that tsunab allows time-series
operators in varlist; see tsvarlist.
The difference between tsunab and fvunab is that fvunab allows factor
variables in varlist; see fvvarlist.
Options
min(#) specifies the minimum number of variables allowed. The default is
min(1).
max(#) specifies the maximum number of variables allowed. The default is
max(32000).
name(string) provides a label that is used when printing error messages.
Examples: within a program
Within a program that did the high-level command parsing using syntax, as
in
syntax varname [if] [in], BY(string) ...
further low-level parsing might be needed. For instance,
capture confirm var `by'
if _rc == 0 {
unab by : `by', max(1) name(by())
}
else {
... something else is done with `by' ...
}
Within a program that allows time-series variable lists, you might have
tsunab myvar : `myvar'
The local macro myvar would then contain the unabbreviated variable list
with time-series operators (if any) in standard form.
Examples: interactive
. sysuse auto
. unab x : mpg wei for, name(myopt())
. display "`x'"
. unab x : junk (gives error message)
. unab x : mpg wei, max(1) name(myopt()) (gives error message)
. unab x : mpg wei, max(1) name(myopt()) min(0) (gives error message)
. unab x : mpg wei, min(3) name(myopt()) (gives error message)
. unab x : mpg wei, min(3) name(myopt()) max(10) (gives error message)
. unab x : mpg wei, min(3) max(10) (gives error message)
. gen time = _n
. tsset time
. tsunab mylist : l(1/3).mpg
. display "`mylist'"
. tsunab mylist : l(1/3).(price turn displ)
. di "`mylist'"
. unab varn : mp
. display "`varn'"
. set varabbrev off
. unab varn : mp
. set varabbrev on
. unab varn : mp
. display "`varn'"
Also see
Manual: [P] unab
Help: [P] varabbrev, [P] syntax, [TS] time, [TS] tsrevar, [P] unabcmd