*! version 1.0 2013-10-08
help cleanchars (vs1.0: 2013-10-08)

Title

cleanchars -- To replace specific characters or strings in variable names and/or variable labels and/or string variable values and/or value label names and levels with stated characters/strings (using 1-1 or m-1 match).

Syntax

cleanchars , in(string) [out(string) vname vlab vval values lower]

Description

cleanchars
is a program that helps out with replacing unwanted/inconvenient characters/strings in the currently active dataset. Entities searched through, and where changes could be applied, are (i) variable names (ii) variable labels
(iii) string variable values (iv) value label names and corresponding level-labels. Moreover, an option directly putting all variable names into lower case is available.
Note: Changes related to variable names depend on the user-written command renvars (Weesie & Cox, 2005).

Options

in(string) Defines the characters/strings to be replaced. Several characters/strings might be stated, where the i:th will then be replaced by the i:th one stated in out (if not the number of strings in out
is 1 or 0 where all symbols/strings will be replaced by either the single stated symbol/string or by the empty string, respectively). This option is mandatory.

out(string) Defines the characters/strings to replace the symbols/strings stated in in. Several characters/strings might be stated but the corresponding number must either equal the
corresponding number in in, where the i:th item will replace the i:th one stated in in, or 1 or 0 where the single symbol/string and empty string will replace all items in in, respectively.
If the option is omitted, such an empty string is assumed.

vname States that variable names should be affected.

vlab States that variable labels should be affected.

vval States that string variable values should be affected.

values States that value label names as well as corresponding level-labels should be affected.

lower States that all variable names should be changed, if needed, to solely using lower case characters.

Note! If none of the options vname, vlab, vval and values are stated then it is assumed that all of them are of interest (i.e. hence then all the four options are marked and used).

Examples

1. Replace all occurrences of Danish letter 'æ' with 'ae' in variable names.

. cleanchars , in("æ") out("ae") vname

2. Replace all occurrences of Swedish letter 'ö' with 'oe' in variable labels.

. cleanchars , in("ö") out("oe") vlab

3. Replace all occurrences of Nordic letter 'å' with 'aa' in string variable values.

. cleanchars , in("å") out("aa") vval

4. Replace all occurrences of chars 'å' and 'æ' with 'a' in value label names and in corresponding label-levels.

. cleanchars , in("å æ") out("a") values

5. Replace all occurrences of string '¤#?' with the empty string in all ways possible (in names of variables, labels. etc.).

. cleanchars , in("¤#?") vname vlab vval values

6. Replace all occurrences of characters 'å', 'æ', 'Å', 'Æ', with 'a' in all ways possible (in names of variables, labels. etc.), where also all variable
names are changed to - if needed - using lower case characters only. Note that leaving out all of the options vname, vlab, vval and values
is equal to stating all of them (working as a default in this way).

. cleanchars , in("å æ Å Æ") out("a") lower

Requires

Stata 10. Moreover, the command depends on the user written function renvars (Weesie & Cox, 2005).

Author

Lars Ängquist

Lars.Henrik.Angquist@regionh.dk

lars@angquist.se

Also see

Help: [help pages on] renvars (user-written; SSC),

describe, codebook, labelbook, label, lookfor, rename, extended_fcn.