help labdeval
-------------------------------------------------------------------------------

Title

labdeval -- Define value labels matching variable names

Syntax

Define new value labels matching variable names

labdeval varlist # "label" [# "label" ...] [, modify replace define(lblname)]

Copy existing value labels

labdeval [varlist] , copy[(lblname)] [replace]

Attach value labels in memory to same-named variables

labdeval [varlist]

Description

labdeval defines value labels matching variable names. Value labels are attached to same-named variables in the dataset.

Specifying integer-to-text mappings defines value labels and attaches them to varlist, using variable names as value label names.

Omitting integer-to-text mappings (and not specifying option copy) attaches already defined value labels in memory to same-named variables. If varlist is not specified it defaults to all numeric variables in the current dataset.

Options

modify modifies existing value labels. See label define.

replace allows existing value labels to be redefined. See label define in Stata 11.0 or higher.

define(lblname) defines a single value label, lblname, and attaches it to all variables in varlist. Specifying define is the same as combining the label define and label values commands.

copy[(lblname)] copies existing value labels. If specified, value label lblname is copied and attached to variables in varlist using variables' names as value label names. Omitting lblname copies each variable's value label and attaches it to the respective variable using its name. Think of copy as renaming each variable's value label to match the variable name. Old value labels are, however, not dropped from memory.

Examples

. sysuse nlsw88 ,clear

Define one value label set (i.e integer-to-text mappings) and attach it to some variables using their names as value label names.

. labdeval never_married south c_city 1 "yes" 0 "no" . describe

Define one value label, yesno, and attach this label to the variables.

. labdeval never_married south c_city 1 "yes" 0 "no" , define(yesno) . describe never_married south c_city

Now reverse the above. That is, make a copy of value label yesno and attach it to variables using their names as value label names.

. labdeval never_married south c_city ,copy(yesno) . describe never_married south c_city

Attach a copy of each variable's value label to that variable, using its name as value label name.

. labdeval ,copy replace . describe

Author

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

Also see

Online: label

if installed: labelrename, valtovar, labutil2