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, statalist.org 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   Abhimanyu Arora <abhimanyu.arora1987@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: renaming variables from first observation
Date   Thu, 25 Aug 2011 10:25:46 +0200

I caught the mistake, thanks to -set trace on-. 'Code' is the second
word of my observation of the first variable and of course a variable
name has to be single worded. But my question on possibility of using
Nick's -renvars- remains.
Best regards
Abhimanyu


On Thu, Aug 25, 2011 at 10:07 AM, Abhimanyu Arora
<abhimanyu.arora1987@gmail.com> wrote:
> Good morning statalist
> I would like to rename my variables var1-var14 to the corresponding
> values from the first observation.
> I followed the post on
> http://www.stata.com/statalist/archive/2004-07/msg00009.html 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-?
>
> Cheers
> Abhimanyu
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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