help elabel parse

Title

elabel parse -- Parse elabel syntax

Syntax

Old syntax (continues to work)

elabel parse
[ description_of_string ]
: [ string_to_parse ]

Modern syntax (requires Stata 16 or higher)

elabel parse
[ description_of_string ]

where description_of_string may contain the elements

{
elblnamelistnewlblnamelist|anything
}mappingsiffusing, options

and any element may be enclosed in square brackets.

string_to_parse contains the elements described in elabel

elblnamelistmappingsiff
eexpusing filename
, options

and typical usage of elabel parse is

program elabel_cmd_mycommand

version 11.2

elabel parse elblnamelist [ mappings ] [ iff ] [ , OPname ] : `0'

code referring to `lblnamelist'

code referring to `mappings'

code referring to `iff'

code referring to `opname'

...

end

or, with Stata 16 or higher

program elabel_cmd_mycommand

version 16

elabel parse elblnamelist [ mappings ] [ iff ] [ , OPname ]

code referring to `lblnamelist'

code referring to `mappings'

code referring to `iff'

code referring to `opname'

...

end

elabel parse defines the following locals

`lblnamelist' contains the unabbreviated list of value
label names

`newlblnamelist' contains the list of new value label names

`anything' contains elblnamelist and newlblnamelist,
as typed

`mappings' contains mappings, as typed

`iff' contains iff followed by eexp, as typed

`using' contains using followed by filename,
as typed, including double quotes

options contain the respective options

Description

elabel parse parses elabel syntax; the command is similar
to Stata's syntax command.

The elements in string_to_parse are matched with the elements
in description_of_string. Elements that do not appear in
description_of_string may not appear in string_to_parse
and if they do, an error message is issued.

Elements that are enclosed in brackets in description_of_string
may appear in string_to_parse but need not appear in
string_to_parse.

Elements that appear in description_of_string and that are not
enclosed in brackets must appear in string_to_parse.

In description_of_string, everything that follows the first comma
is interpreted as a part of options, meaning that options must
be mentioned last; all other elements may appear in any order but may
not be mentioned more than once. The elements in description_of_string
are described below.

In string_to_parse all elements must appear in the indicated
position.

elabel parse exits with return code r(197)
if there is an error in description_of_string or the command
itself, not in what is parsed.

Description of string

elblnamelist

If you type elblnamelist, string_to_parse must contain at
least one (existing) value label name. If you type [elblnamelist],
string_to_parse may contain one or more value label names. If you
do not type anything, string_to_parse may not contain an
elblnamelist.

You may type elblnamelist(spec), where spec is one or more
of

newlblnamelist allows new (not yet defined) value label names
in elblnamelist. All value label names are returned in
`lblnamelist' in the specified order. New value label names, if
any, are additionally returned in `newlblnamelist'. Note that
string_to_parse might contain only new, not yet defined, value
label names.

nomemory treats value label names attached to variables as
if they were defined in memory.

current implies nomemory and restricts not yet defined
value labels to those in the current label language.

abbrevok allows abbreviated value label names; if combined with
newlblnamelist, abbreviated value label names are treated as
existing value labels, not new value label names.

varvaluelabel allows
varname:elblname in
elblnamelist. Returned in `varvaluelabel' is
(varname [varname ...] lblname)
[ (varname ... lblname) ... ]; also see
elabel varvaluelabel.

elblnamelist may not be combined with anything. The
unabbreviated list of value label names is returned in `lblnamelist'.

newlblnamelist

If you type newlblnamelist, string_to_parse must contain
at least one new (not yet defined) value label name. If you type
[newlblnamelist], string_to_parse may contain one or more
new value label names. If you do not type anything, string_to_parse
may not contain any new value label names.

You may type newlblnamelist(spec), where spec is one or more
of

elblnamelist allows existing value label names in
newlblnamelist. All value label names are returned in
`lblnamelist' in the specified order. New value label names
are additionally returned in `newlblnamelist'. Note that
string_to_parse must contain at least one new, not yet defined,
value label name.

nomemory treats value label names attached to variables as
if they were defined in memory.

current implies nomemory and restricts not yet defined
value labels to those in the current label language.

abbrevok allows abbreviated value label names; abbreviated value
label names are treated as existing value labels, not new value label
names.

varvaluelabel allows
varname:newlblname in
newlblnamelist. Returned in `varvaluelabel' is
(varname [varname ...] lblname)
[ (varname ... lblname) ... ]; also see
elabel varvaluelabel.

newlblnamelist may not be combined with anything but may
be combined with elblnamelist. The list of new value label names
is returned in `newlblnamelist'.

anything

If you type anything (or [anything]), string_to_parse
must (or may) contain something in the place of elblnamelist, or
newlblnamelist; these elements are, however, not parsed but returned
as typed.

anything may not be combined with any of elblnamelist or
newlblnamelist. Whatever is typed in place of elblnamelist
and newlblnamelist is returned in `anything'.

mappings

If you type mappings, string_to_parse must contain
mappings. If you type [mappings], string_to_parse may
contain mappings. If you do not type anything, string_to_parse
may not contain mappings. In any case, mappings are indicated
by a number like 42, or an extended missing value code like .f,
or an equals sign, optionally enclosed in parentheses, i.e., =, or,
(=...). Everything following one of these elements is treated as
a part of mappings, except iff eexp, using
filename, and options.

You may type mappings(broad) to request that any element in
string_to_parse that is not a name (possibly enclosed in parentheses
and possibly containing wildcard characters) is treated as a part of
mappings. This might be useful when mappings is combined with
anything.

mappings are returned in `mappings' as typed.

iff

If you type iff, string_to_parse must contain an
iff eexp. If you type [iff], string_to_parse
may contain an iff eexp. If you do not type anything,
string_to_parse may not contain an iff eexp. In any
case, everything following the word iff is treated as a part of
eexp, except using filename and options.

Returned in `iff' is iff followed by eexp, as typed.

If version is set to less than 16, you may type if in
place of iff and if you do, string_to_parse may contain
if or iff; either way, returned in `if' is if
followed by eexp.

using

If you type using, string_to_parse must contain using
filename. If you type [using], string_to_parse may
contain using filename. If you do not type anything,
string_to_parse may not contain using filename.

Returned in `using' is using followed by filename,
as typed, including any double quotes.

options

The rules for options are the same as those for Stata's
syntax command. Technically,
elabel parse passes the description thru to syntax.

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: syntax, gettoken, label

if installed: elabel