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

st: RE: common prefix to all variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: common prefix to all variables
Date   Mon, 24 May 2004 17:59:28 +0100

Your example here, if literal, will fail 
because of the difference between `variable' 
and `variablen'. 

-unab- is unnecessary here. 

foreach x of var * { 
	rename `x' v_`x' 
} 

should work. 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Hans J.
> Baumgartner
> Sent: 24 May 2004 17:56
> To: statalist
> Subject: st: common prefix to all variables
> 
> 
> Hello statalist,
> 
> I would like to give all variables a common prefix.
> 
> I thought first of using unab in a foreach loop:
> 
> 	unab variable : _all
> 	foreach x in `variablen' {
> 		rename `x' v_`x'
> 	}
> 
> Although Stata correctly unabbreviates my varlist, I cannot call this 
> varlist in a foreach loop nor in a for any loop.
> 
> All suggestions are welcomed
> 
> Best wishes
> Hans
> 
> 
> -- 
> Hans J. Baumgartner
> DIW Berlin
> German Institute for Economic Research
> Dept. Public Economics
> K�nigin-Luise-Str. 5; 14195 Berlin; Germany
> Tel.: +49/30/89789-307; Fax.: +49/30/89789-114
> http://www.diw.de
> http://www.hansbaumgartner.de
> 
> 
> *
> *   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