Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Rename problem: r(110) already defined


From   "Friedrich Huebler" <[email protected]>
To   [email protected]
Subject   Re: st: Rename problem: r(110) already defined
Date   Wed, 13 Feb 2008 14:20:32 -0500

Thanks to everyone who responded to my -rename- problem. I added an IF
command to the -foreach- loop and now have a solution that (a) ignores
variable names that are already lowercase and (b) stops execution of
the do-file if the names of two variables in the data differ only with
regard to upper or lower case.

ds
local vars "`r(varlist)'"
foreach v of local vars {
  local newname = lower("`v'")
  if "`v'" != "`newname'" rename `v' `newname'
}

The lines above can be replaced by a single command if -renvars- is installed.

. renvars, lower

Thanks again.

Friedrich
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index