*! version 17.0 09may2024

Title

trim_vars trims blanks in a varlist specified by the user.

Syntax

trim_vars varlist

Description

The trim_vars command removes leading and trailing Unicode whitespace characters
and blanks, as well as multiple, consecutive internal blanks, from the list of
variable[s] the user inputs.

trim_vars finds all of the string variables in the current dataset and performs
trimming on them if _all or * are specified in varlist.

trim_vars performs trimming on the desired string variable[s] if a list of one or more
string variables are specified in varlist.

trim_vars performs trimming only on the string variables if a combination of string and
numeric variables are specified in varlist.

However, trim_vars issues an error if no string variables are found.

Examples

trim_vars _all // Trim all string variables in current dataset
trim_vars strvar1 strvar2 strvar3 // Trim string variables specified
trim_vars strvar1 strvar2 numvar1 numvar2 // Trim only the string variable specified

Remarks

See ustrtrim() and stritrim() for more on Stata's trim functions.
See also ds for more on listing variables with specified properties.

Author

Kaifeng Deng, Washington, DC, USA
deng.28@outlook.com