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

[no subject]


From   Stas Kolenikov <[email protected]>
To   [email protected]
Date   Tue, 13 Jul 2004 16:31:53 -0400 (EDT)

Sasha,

> I would like to add index i to some variable names. What is wrong with
> my code:
>
> variables: id a b c d
>
> foreach var of varlist a-d {
>   rename "`var'"  "`var'""_i"
> }

first of all, there is no -id- in your -varlist-

second, let's see how Stata expands this stuff. For the first item in the
list, it'll become

rename "a" "a""_i"

I am not sure the second one is a valid Stata name. All you need is to
omit the kavychki, if you know what I mean :)). So, your sequence would
probably be

foreach var of varlist a-d {
  rename `var'  `var'_i
}

So your -a- variable would be renamed -a_i-, etc. Is it what you want?

 ---                                    Stas Kolenikov
 --       Ph.D. student in Statistics at UNC-Chapel Hill
 - http://www.komkon.org/~tacik/  -- [email protected]

* This e-mail and all attachments to it are not intended to provide any
* reasonable point of view and was transmitted to you in error. It
* should be immediately deleted by all recipients unless they really
* enjoy communicating with the author :). Other restrictions apply.

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