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

st: RE: modification on <renpfix>?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: modification on <renpfix>?
Date   Mon, 6 Dec 2004 23:09:27 -0000

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/



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