Title
labrecode -- Modify value labels and recode variables they are attached to
Syntax
labrecode lblname-list (rule) [(rule) ...] [, options]
where rule is
numlist = # ["label"]
Description
labrecode 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 labrecode combines text associated with values in numlist and attaches it to #.
Caution: modifiactions affect all variables that have the same value label as one of the value labels in lblname-list attached. The program alters existing variables.
Options
novar recodes value labels but not variables.
nolabel prevents labrecode 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.
nostrict allows variable names in lblname-list. If specified, any variable that has the same value label as one of the variables in lblname-list attached is recoded.
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.
. labrecode racelbl (2 = 3)
Do the same as above, but keep text "other" attached to value 3.
. labrecode racelbl (2 = 3) ,nolabel
Do the same as above, but attach text "other black" to value 3.
. labrecode racelbl (2 = 3) ,add
Do the same as above, but delete value 3 from racelbl.
. labrecode 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.
. labrecode occupation (1 2 = 14 "Prof./Managers") (9/10 = 10) ,nostrict
Option nostrict allows variable name occupation in lblname-list. 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.
. labrecode racelbl (1=3)(3=1)
Author
Daniel Klein, University of Kassel, klein.daniel.81@gmail.com
Also see
Online: label
if installed: labvalch, rev, labutil2