Stata is a case-sensitive application, which can sometimes cause trouble. Therefore, we might want to convert all variable names or the values of all string variables to lowercase before further data processing. This post gives a quick method to do this.

Lowercase all variable names

The rename command is used for this purpose. Instead of renaming variables one by one, we can rename all variables with a single command:

rename *, lower or rename _all, lower

A related post can be found at Mingze Gao wrote a macro to achieve the same function in SAS (here).

Lowercase the values of all string variables

ustrlower(string) or strlower(string) will do the trick. Instead of applying the ustrlower or strlower function to string variables individually, we can benefit from lowercasing the values of all string variables in a short loop:

In this loop, ds is used to find string type variables and foreach is used to iterate over each string variable to replace its values with the lowercase version.

Categorized in: