help encodelabel

Title

encodelabel -- Encode string variable into categorical variable

Syntax

encodelabel
varname
[if] [in]
,
{generate(newvar)|replace}
label(name)
[min(#) nosort]

Description

encodelabel is an alternative to encode with the label()
option. encodelabel adds to the value label starting with the value 1
and skipping the values that are already present.

Do not use encodelabel if varname contains numbers that merely
happen to be stored as strings; instead, use generate newvar =
real(varname) or destring; see real() or
[D] destring.

Options

generate(newvar) specifies the name of the variable
to be created. Either generate() or replace is required.

replace specifies that the encoded (numeric categorical) variable
replaces varname; any notes and characteristics
are stripped. Either replace or generate() is required.

label(name) is required and specifies the name of the value label
to be used and added to; the named value label must already exist.

min(#) specifies the first value to be added to the value label. The
default value is # = 1.

nosort prevents alphanumeric sorting of (the levels of) varname
when adding to the value label; new labels are added according to the current
sort order.

Examples

None; see the examples in encode.

Acknowledgments

encodelabel first appeared on
Statalist
as an answer to a question from Bruce McDougall.

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: encode

if installed: sencode, multencode