help elabel swap

Title

elabel swap -- Swap value labels

Syntax

Basic syntax

elabel swap
oldlbl
[ {newlbl|.}
[ oldlbl
[ {newlbl|.}
[ ... ] ] ] ]

Extended syntax

elabel swap
(oldlbl1 oldlbl2 [ ... ])
({newlbl1|.} [ {newlbl2|.} ... ])

where oldlbl and oldlbl1, oldlbl2, ... may
contain the wildcard characters *, ~, and ?

newlbl and newlbl1, newlbl2, ... may be
elblname or newlblname

Description

elabel swap interchanges value labels, i.e., detaches value
labels from variables and, optionally, attaches new value labels
to variables.

The command complements elabel values,
which attaches and detaches value labels from a varlist.

In the basic syntax, omit the rightmost newlbl (or specify .)
to detach oldlbl from all variables to which it is attached. If
newlbl is specified, it is attached to all variables that previously
had the respective oldlbl attached.

In the extended syntax, the mapping of oldlbl to newlbl is
one-to-one. If only one newlbl is specified, this value label is
attached to all variables that previously had one of oldlbl1,
oldlbl2, ... attached.

Value labels are swapped in all label languages.

Examples

Load example dataset

. sysuse nlsw88

Detach value label occlbl form occupation
(and any other variable that has occlbl attached)

. elabel swap occlbl

Detach marlbl form married and attach new (not yet defined)
value label yesno to married

. elabel swap marlbl yesno

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: label

if installed: elabel