help labrec
-------------------------------------------------------------------------------

labrec has been superseded by labrecode which is also part of labutil2 package. labrec will not be removed from the package, but there will be no further updates. See Remarks.

Title

labrec -- Modify value labels and recode variables they are attached to

Syntax

labrec namelist (rule) [(rule) ...] [, options]

where namelist is a list of value label names, a varlist, or a combination of the two

rule is

numlist = # ["label"]

Description

labrec modifies value labels and recodes all variables they are attached to accordingly. In value labels, values specified in numlist are changed to # and any text associated with values in numlist is deleted from the value label. A user defined label is associated with #. If no label is specified labrec combines text associated with values in numlist and attaches it to #.

Caution: Modifications affect all variables that have the same value label as one variables in namelist attached. The program alters existing variables. See Remarks.

Options

nochange recode value labels but not variables.

nolabel prevents labrec from creating labels if the user does not provide them. Default is to combine text associated with values in numlist and attach it to #. Note that specifying nolabel does not detach text from #. To do this specify "" as label in rules.

add adds text associated with values in numlist to text associated with # if no user defined label is provided. May not be combined with nolabel.

separate(chars) specifies the separator between labels. Default is to use space (" "). May not be specified with nolabel.

nodelete does not delete text associated with values in numlist from value labels. This option is seldom used.

Remarks

labrec violates Stata conventions. Specifying variable foo in namelist, changes variable foo. It also changes variable bar, if bar has the same value label, say foobar, attached. In fact, any variable that has value label foobar attached will be recoded, even though neither variable bar nor value label name foobar is ever specified. I thank Daniel Possenriede for bringing this to may attention again. labrec will continue to work the way it did, but is superseded by labrecode. Specifying variable names in namelist is allowed with labrecode, but this feature has to be requested by the user.

Examples

In the nlsw88 dataset, change value 2 in racelbl and race to value 3. Attach text "black" to value 3. Delete the association between value 2 and text "black" from racelbl.

. labrec racelbl (2 = 3)

Do the same as above, but keep text "other" attached to value 3.

. labrec racelbl (2 = 3) ,nolabel

Do the same as above, but attach text "other black" to value 3.

. labrec racelbl (2 = 3) ,add

Do the same as above, but delete value 3 from racelbl.

. labrec racelbl (2 = 3 "")

In value label occlbl change values 1 and 2 to value 14 and attach text "Prof./Managers". Also change value 9 to value 10. Attach text "Farmers Farm laborers" to value 10.

. labrec occupation (1 2 = 14 "Prof./Managers") (9/10 = 10)

Note that option add is not needed here, because value 10 is part of numlist. Variable occupation is recoded accordingly as would be any other variable using value label occlbl.

Reverses value label racelbl and recode variable race accordingly.

. labrec race (1=3)(3=1)

Author

Daniel Klein, University of Bamberg, klein.daniel.81@gmail.com

Also see

Online: label

if installed: labvalch, rev, strrec, labutil2