<>
Which could be shortened to
/* Begin */
clear
set obs 1000
g abc_56epi=0
g def_56epi=0
g ghi_56epi=0
foreach x of varlist *_56epi {
local y_`x' = regexr("`x'", "_56epi", "_45epi")
rename `x' `y_`x''
}
/* End */
because foreach with a -varlist- happily does the job of -ds-
HTH
Martin
_______________________
----- Original Message -----
From: "Tirthankar Chakravarty" <[email protected]>
To: <[email protected]>
Sent: Friday, May 01, 2009 1:52 PM
Subject: Re: st: Changing the suffix on variable names
Here is another, clunkier, option:
/* Begin */
clear
set obs 1000
g abc_56epi=0
g def_56epi=0
g ghi_56epi=0
ds *_56epi
local varlist=r(varlist)
foreach x of local varlist {
local y_`x' = regexr("`x'", "_56epi", "_45epi")
rename `x' `y_`x''
}
/* End */
T
On Fri, May 1, 2009 at 11:57 AM, sdm1 <[email protected]> wrote:
I have 150 variables all with the same suffix. I'd like to be able to
change this suffix to a different suffix (eg from '_56epi' to '_45epi'.
Is
there an easier way to do this than using the 'rename' command 150 times?
Many thanks.
Steve
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
--
To every ω-consistent recursive class κ of formulae there correspond
recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
belongs to Flg(κ) (where v is the free variable of r).
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/