help elabel recode

Title

elabel recode -- Recode value labels

Syntax

elabel recode
elblnamelist
(rule)
[ (rule) ... ]
[ iff eexp ]
[ , options ]

where rule is
{#|numlist}
=
{#|numlist}
[ "label" [ "label" ... ]]

Description

elabel recode recodes values in value labels. Values that are not
specified in rules are left unchanged.

If numlist on the right-hand side of a rule contains more
than one value, it must contain as many values as the numlist on
the left-hand side; the mapping of values is one-to-one. Likewise, if
more than one label is specified, the number of labels must
match the number of values in the numlist on the right-hand
side. If no label is specified, the label that is associated
with the (last specified) respective value on the left-hand side is
used.

numlist is interpreted in the usual way and, additionally, may
contain sequences of missing value codes such as .a/.c. Noninteger
values are not allowed in numlist. If numlist or label
contain spaces, label must be enclosed in quotes.

Remember that value labels may be attached to more than one
variable. Thus, changing one set of value labels might affect
more than one variable. Conversely, variables might have
different value labels attached in different
label languages; consider recoding such
value labels, too.

Options

define(newlblnamelist) specifies names for the value labels that
will contain the recoded values. newlblnamelist may contain
varname:lblname.

If neither prefix() (see below)
nor define() is specified, existing value labels are modified.

prefix(str) is an alternative to define(); the option
prefixes old value label names with str and stores the recoded
values under those new value label names.

If neither define() (see above)
nor prefix() is specified, existing value labels are modified.

separator(char), in rules that do not specify a label,
combines labels of the values on the left-hand side using char
as the separator.

copyrest copies values (and associated text) that are excluded
by iff eexp from old value labels.

recodevarlist recodes all variables that have one of the
recoded value labels attached (in any label language) according
to rules. If variables have different value labels attached
in different label languages, all value labels must be recoded;
otherwise, an error message is issued. Option recodevarlist
returns the names of recoded variables in r(varlist).

Remember that elabel recode expands ranges, such as
42/73, in rules to the integer sequence from 42
to 73. Option recodevarlist applies these expanded
rules to recode variables; this is different from how
the recode command interprets ranges in rules.

varlist additionally returns, in r(varlist), the variable
names that have one of the recoded value labels attached (in any label
language). Note that variables might have different value labels
attached in different label languages; consider recoding such value
labels, too. Also, see option recodevarlist.

dryrun does not recode values but lists implied new value labels
below old value labels.

Examples

Define value label agreelbl

. elabel define agreelbl 1 "agree" 2 "neutral" 3 "disagree"

Change the direction of values in agreelbl from 1, 2, 3 to 3, 2, 1
and store the result in value label disagreelbl

. elabel recode agreelbl (1/3 = 3/1) , define(disagreelbl)

Change value 2 in both value labels to .a, assigning the label "neither nor"; do
not perform changes but list old and implied new value labels

. elabel recode agreelbl disagreelbl (2 = .a "neither nor") , dryrun

Saved results

elabel recode saves the following in r():

Macros

r(rules) transformation rules with all labels removed

r(varlist) variables that have one of the recoded
labels attached (option varlist only)

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: label

if installed: elabel adjust, elabel