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

RE: st: upper case to lower case for all variable names

From   "Nick Cox" <>
To   <>
Subject   RE: st: upper case to lower case for all variable names
Date   Wed, 16 Nov 2005 09:53:45 -0000

It's worth explaining the bridge between 
this and much shorter solutions given by 

The assumption that variable names go 
from VAR1-VAR999 can be replaced by 
a specification 


and in turn by the wildcard * or _all. 

Then you have no need to drop existing macros. 
You can do the renaming on the fly: 

foreach v of var * { 
	rename `v' `=lower("`v'")' 

A small risk with this last trick is that
"all variables" could include temporary variables
with names like __00000A. -rename- that to 
__00000a and you will have programming problems. 

However, when this is done it is, I guess, 
virtually always with the main dataset, and interactively, 
so no temporary variables are in sight. 


Rafal Raciborski
> assuming your variables go from VAR1 to VAR999:
> macro drop _all
> foreach i of varlist VAR1-VAR999 {
> 	local j = lower("`i'")
> 	rename `i' `j'
> 	macro drop j
> }

*   For searches and help try:

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