help labvalch3

Title

labvalch3 -- Change value labels

Syntax

labvalch3 [namelist] , transformation_option
[options]

where namelist is a list of value label names or, if variables
is specified, a varlist

transformation_options
upper change value labels to uppercased characters

lower change value labels to lowercased characters

prefix(stub) prefix value labels with stub

suffix(stub) suffix value labels with stub

subst(this that) in value labels change this to
that

before(before) remove before and any text following

after(after) remove after and any text preceding

noexclude do not remove before or after

strfcn(strfcn()) apply string function
strfcn() to value labels

symbol(str) use symbol as placeholder in strfcn()

selection_options
variables parse namelist as varlist

valid(numlist) change value labels associated with valid
numbers

invalid(numlist) do not change value labels associated with
invalid numbers

Description

labvalch3 changes value labels specified in namelist. If namelist
is not specified, all value labels in memory are changed.

If more than one transformation option is specified, labvalch3 applies
options in the following order. Firstly value labels are changed to upper- or
lowercased characters. Secondly, all occurrences of this are changed to
that. Next before or after remove text. If a
string function is specified, this function is then
applied to the upper/lowercased, substituted value labels. Any prefix
and/or suffix is added last.

Options

Options

upper changes value labels to uppercased characters. May not be
specified with lower.

lower changes value labels to lowercased characters. May not be
specified with upper.

prefix(stub) prefixes value labels with stub. May be combined
with suffix(). Use double quotes if stub contains embedded
spaces.

suffix(stub) suffixes value labels with stub. May be combined
with prefix(). Use double quotes if stub contains embedded
spaces.

subst(this that) substitutes all occurrences of this in value
labels with that. Use double quotes if this or that
contain embedded spaces. Value labels in which this is not found
are left unchanged.

before(before) removes before and any text following from value
labels. Thus, value labels will be changed to contain any text preceding
before. Value labels in which before is not found are left
unchanged. May not be specified with after.

after(after) removes after and any text preceding from value
labels. Thus, value labels will be changed to contain any text following
after. Value labels in which after is not found are left
unchanged. May not be specified with before.

noexclude prevents labvalch3 from removing before or
after from value labels. Specifying before(e) noexclude will
change value label Domestic to Dome. Specifying before(e)
will change value label Domestic to Dom.

strfcn(strfcn()) applies any string function
to value labels. In strfcn use placeholder @ to refer to value
labels. The general from of this option is
strfcn(strfcn("@", args)).

symbol(str) use str as placeholder for value labels in
strfcn. Default placeholder is @.

variables specifies that namelist is a varlist. If namelist
is not specified it defaults to _all, meaning all variables in the
dataset.

valid(numlist) changes value labels associated with numbers specified
in numlist.

invalid(numlist) does not change value labels associated with numbers
specified in numlist.

Examples

. sysuse auto

. labvalch3 origin ,suffix(" Automobile")

. labvalch3 foreign ,variables subst("Automobile" "Car")

. labvalch3 ,upper

. labvalch3 ,strfcn(proper("@"))

. labvalch3 foreign ,before(e) valid(1)

Acknowledgments

This ado was suggested by Dimitriy V. Masterov on
Statalist.

The name labvalch3 is in line with labvalch from labutil
(see labutil) package by Nick Cox, who also originated the
tranformation options in his (much richer) labvarch. Number 3 is
chosen because of the (nice) ad hoc solution labvalch2 by Eric Booth.
Also, by coincidence, labvalch3 changes the third element in
label define lblname # label.

Author

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

Also see

Online: label, string_functions

if installed: strrec, labcd, labcopy, labdel,
lablog, labdtch, labmap, labnoeq, labvarch,
labvalch, labmask, labvalclone, labeldup,
labelrename