Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: change case of variable names

From   Gary Longton <>
Subject   Re: st: change case of variable names
Date   Mon, 01 Aug 2005 13:50:26 -0700

Lachenbruch, Peter wrote:

I have a data set with about 600 variables and all are in upper case. Is there a simple way to make the case lower?

I played with ren ARM lower("ARM") that didn't work. I suspect I'm missing something very obvious. What I'd eventually like to do is something like

foreach v of varlist A-Z{

ren `v' lower(`v')


but that won't work.
This looks like the right idea to me - one minor problem is that rename won't take an expression for the second argument, though you can get around this with the expression expansion operator `=exp'. Also, within the string function, lower(), enclose `v' in double quotes so that lower() is evaluating the variable name and not the variable itself.

foreach v of varlist _all {
rename `v' `=lower("`v'")'

- Gary

* For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index