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

Re: st: quick question


From   James Jetton <jetton@pilot.msu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: quick question
Date   Thu, 26 Feb 2004 05:25:51 -0500

This can be simplified further:

 foreach var of varlist _all {
   local newname = lower("`var'")
   capture rename `var' `newname'
   }


James



On Feb 25, 2004, at 5:38 PM, Gary Longton wrote:

But I think you were also on the right track with what Nick Cox might call a "first principles" approach, using -foreach- and the lower() function. You just need to ensure that lower() is looking at the string variable name as an argument, rather than at the variable itself, by enclosing in double quotes. Eg.

foreach var of varlist _all {
local newname = lower("`var'")
if "`var'" ~= "`newname'" {
rename `var' `newname'
}
}

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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