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: renaming variables from first observation

From   Nick Cox <>
Subject   Re: st: renaming variables from first observation
Date   Thu, 25 Aug 2011 09:27:49 +0100

This should work, so long as your values in the first observation are
legal variable names. It seems that they are not.

As for storing values in a macro: That is precisely what your code is
doing here, so I don't know what underlies that question.

-renvars- is by Jeroen Weesie and myself (SJ). It can't help you here.

Please show us the results of

. list var1-var14 in 1


On Thu, Aug 25, 2011 at 9:07 AM, Abhimanyu Arora
<> wrote:

> I would like to rename my variables var1-var14 to the corresponding
> values from the first observation.
> I followed the post on
> and
> modified it for my purpose.
> but I got this error
> . forvalues k = 1/14  {
>  2.   local newname  = var`k'[1]
>  3.   ren var`k'  `newname'
>  4. }
> Code not allowed
> Also is it posible to store the values of an observation in a macro?
> Perhaps I could then use Nick Cox's -renvars-?

*   For searches and help try:

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