help for replacebylab

Title

replacebylab -- Replace values by drawing on value labels

Table of contents

Syntax
Description
Options
Remarks
Examples
Author

Syntax

replacebylab varlist [if exp] [in range], options

Both options label(string) and setvalue(numeric) are required.

Description

replacebylab changes values on basis of labels assigned to values. Every value with the respective label is recoded to a pre-specified new value.
In this process, every value label of every whole number between the minimum and maximum value
of the respective variables is examined. replacebylab applies to numerical variables only.

Options

label(string) specifies the label of the values which should be recoded.

setvalue(numeric) specifies the new value to which every value with the label(string) should be changed.

substr optionally forces replacebylab to recode all values with labels which include the string defined by label(string).

newlabel(string) is optional and contains a label which will be assigned to the new value (defined by setvalue(numeric)).

dellab is optional and specifies that the old value labels will be deleted.

display is optional and results in an output showing which values have been replaced in each variable.

Remarks

replacebylab crawls the value label definitions of every specified variable. This is done from the lowest to the highest value for each variable. In a data set with (many) high dimensional variables, this may result in
poor performance of replacebylab. In this case, it is highly recommended to exclude the respective variables.

replacebylab will not work with an active numlabel command. numlabel prefixes the numeric values to a label. Hence, "don´t know" does not correspond to "99. don´t know".

Examples

Recode all "don´t know" answers to -99 for the whole data set.

. replacebylab _all, label(don´t know) setvalue(-99)

Recode all answers which include the substring "yes" to 1 for variables v1, v2, and v3. Additionally, 1 will be labeled "positive" by applying the newlabel(string) option.

. replacebylab v1 v2 v3, label(yes) setvalue(1) substr newlab(positiv)

Recode all "don´t know" answers to -99 for the whole data set. Additionally, display is specified to get information on which values are replaced.

. replacebylab _all, label(don´t know) setvalue(-99)

Author

Tobias Gummer, GESIS - Leibniz Institute for the Social Sciences, tobias.gummer@gesis.org