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

Re: st: RE: modification on <renpfix>?


From   "Danielle H. Ferry" <[email protected]>
To   [email protected]
Subject   Re: st: RE: modification on <renpfix>?
Date   Mon, 6 Dec 2004 18:13:04 -0500

Much thanks, again.

On Dec 6, 2004, at 6:09 PM, Nick Cox wrote:

Yes. -rensfix- by Stephen Jenkins and myself
is a deliberately created sibling (STB-59).

A more general command yet capable of doing
this, what -renpfix- does, and much more is
-renvars- from Jeroen Weesie and myself
(STB-60).

Having said that, minimalists and despisers
of ad hoc tools would want to mention the
use of -foreach- here:

foreach v of var *_ja {
	local new : subinstr local v "_ja" "_1"'
	rename `v' `new'
}

or

foreach v of var *_ja {
	rename `v' `: subinstr local v "_ja" "_1"'
}

Similarly,

foreach v of var *_fe {
	rename `v' `: subinstr local v "_ja" "_2"'
}

In other words, you can knit your own replacements
in one move on the fly.

Jeroen Weesie I think has mixed feelings about
-renvars- given the existence of -foreach-.
I feel somewhat the same way, but guess that there
are users who might like -renvars- but
who draw the line at working out their own macro
manipulations each time they have problems like this.
	
Nick
[email protected]

Danielle Ferry

Is there a command similar to <renpfix> where instead it renames all
variables that END with old_stub to END with new_stub? If not, can
anyone suggest a  relatively easy way of doing this for a
large number
of variables that all end with the same stub? I.e., I want to rename
everything *_ja to *_1 and everything *_fe to *_2, etc. Thanks.
*
*   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/

*
*   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