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

st: RE: Re: easier way to rename?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: easier way to rename?
Date   Sun, 15 Sep 2002 18:04:48 +0100

Radu Ban

> I want to rename my variables (which now have long names 
> since they come
> from an excel sheet). I would like to know if there is a 
> quick way to rename
> a recurring word to an abbreviation.

Marcela Perticara
 
> take a look at renvars
> 
> findit renvars
> 
> I think it has what you want.
> 

It may be of interest to compare with a first 
principles solution. 

renvars , sub(households hh) 

foreach v of var * { 
	local new : subinstr local v "households" "hh" 
	if "`new'" != "`v'" { 
		rename `v' `new' 
	}
} 

-renvars- may look easier, but you have 
to find out about it, and find out what 
the syntax is. The other solution makes 
use of more general tools. Admittedly 
the macro function -subinstr- is more a programmer's 
tool. 

Nick 
[email protected] 
*
*   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