Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: rename

From   Nick Cox <>
Subject   Re: st: rename
Date   Tue, 7 Aug 2012 18:48:29 +0100

-rename- as such places absolutely no restrictions on the use of
locals in -rename- commands for the very simple and very fundamental
reason that all macro references are interpreted before -rename- gets
to work. -rename- never sees any macro references, just their
interpretations as macro contents.

That said, let's emphasise that -rename-'s language is based on
extensive use of wildcards.

Either way, the heart of David's question seems to be whether a common
stub is needed for -rename- to work well, if at all, and the answer is

-rename- can be used with a first argument as general as (*), meaning
all variables, so there are no presumptions on the structure of
variable names.

Otherwise I think we need to see concrete examples to comment on
apparent difficulties here.


On Tue, Aug 7, 2012 at 6:27 PM, Airey, David C
<> wrote:

> With the new rename group command, can you use locals to rename a very
> large number of variables from an old name set to a new name set where
> there will be no stub used in either set?
> The syntax is
> rename (old1 old2) (new1 new2)
> but can locals be used inside the parentheses to represent a long list
> of variable names to be switched? I can generate the locals using code
> rather than typing.
> Otherwise, what is the best way to rename a whole bunch of variables
> to new names where the variables do not have stubs.
> I can do the renaming using a reshape and merge, but it seems clunky.
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index