-------------------------------------------------------------------------------
help for labvarch
-------------------------------------------------------------------------------

Change variable labels

labvarch [varlist] [ , transformation_option display test symbol(str) ]

where transformation_option is one of

upper lower

prefix(str) postfix(str) (synonym suffix(str))

presub(str1 str2) postsub(str1 str2)

before(str) after(str)

from(str) to(str)

subst(str1 str2)

predrop(#) postdrop(#)

trim(#)

map(string exp)

Description

labvarch changes variable labels for the variables listed in varlist. If not specified, varlist defaults to _all.

One selected transformation_option is applied to each variable label for each variable in varlist.

Options

One of the following transformation_options should be specified. Where appropriate, remember to use " " to bind strings containing spaces.

upper converts the variable labels to uppercase lower converts the variable labels to lowercase prefix(str) prefixes variable labels with str postfix(str) postfixes variable labels with str. suffix(str) is an exact synonym presub(str1 str2) replaces the leading string str1 by str2 in variable labels. str2 may be empty postsub(str1 str2) replaces the trailing string str1 by str2 in variable labels. str2 may be empty before(str) selects text before (i.e. deletes any text including and after) the first occurrence of str in variable labels. Labels not containing str are not changed after(str) selects text after (i.e. deletes any text before and including) the first occurrence of str in variable labels. Labels not containing str are not changed from(str) selects text from (i.e. deletes any text before) the first occurrence of str in variable labels. Labels not containing str are not changed to(str) selects text to (i.e. deletes any text after) the first occurrence of str in variable labels. Labels not containing str are not changed Thus given the variable label foreign==Domestic, before(==) returns foreign, after(==) returns Domestic, to(==) returns foreign== and from(==) returns ==Domestic. subst(str1 str2) substitutes (all occurrences of) str1 by str2 in variable labels. str2 may be empty predrop(#) removes the first # characters from variable labels postdrop(#) removes the last # characters from variable labels trim(#) keeps (at most) the first # characters from variable labels, dropping the remaining characters: note that trim(0) deletes variable labels map(string_exp) specifies a rule for building new variable labels from existing variable names. By default @ is the placeholder for existing names. This placeholder can be changed by specifying symbol( ).

display specifies that describe be run to show changes.

test specifies that each change is displayed but not performed.

symbol(str) specifies a symbol is to be used as a placeholder for the existing name in the map expression. The default is @. The symbol used should not include characters used in existing variable names. It is difficult to imagine why you might want to use this option.

Examples

. labvarch *, lower

. labvarch log*, map(@)

. labvarch log*, subst(log "log ")

. labvarch f*, pref("First ")

. labvarch f*, suff(" (first)")

. qui tab rep78, gen(r)

. for any before to after from: labvarch r?, X(==) test

. labvarch d*, before(" ") (usually, first word selected)

Author

Nicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk

Acknowledgements

Fred Wolfe was the stimulus for this program, which is based on renvars, jointly written by Jeroen Weesie.

Also see

On-line: label, labedit (if installed), copydesc (if installed)