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

st: Extracting variable names for use as string lists


From   "David Fisher" <[email protected]>
To   [email protected]
Subject   st: Extracting variable names for use as string lists
Date   Thu, 14 Jul 2005 13:59:10 +0000

Hi all,

Is there any way to create a list of variable names, either in string form or some other way, that could then be manipulated using "foreach" and the like?

The problem I have is as follows:
I would like to rename multiple variables in a consistent way -- that is, to abbreviate their names to 8 characters if they are any longer than this (using 'abbrev'). I would like to use a structure something like:

foreach x in [list of variable names] {
if length(`x')>8 {
rename `x' abbrev(`x',8)
}
}

Thanks for your help.
David Fisher.


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