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: AW: renaming variables


From   Abhimanyu Arora <abhimanyu.arora1987@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: AW: renaming variables
Date   Fri, 21 May 2010 11:05:43 +0200

Thanks a  lot Martin for the more efficient method (as always)
Abhimanyu

On Fri, May 21, 2010 at 10:50 AM, Martin Weiss <martin.weiss1@gmx.de> wrote:
>
> <>
>
>
>
> *************
> //create vars
>
> clear*
> set obs 1
>
> forv i=53(3)108{
>        gen var`i'=1
> }
>
> //-rename-
> loc start 1990
>
> foreach var of varlist var*{
>        ren `var' `="year"+string(`start')'
>        loc ++start
> }
> *************
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Abhimanyu Arora
> Gesendet: Freitag, 21. Mai 2010 10:45
> An: statalist@hsphsun2.harvard.edu
> Betreff: st: renaming variables
>
> Dear statalist
> I would like to rename my variables var53....var108 such that var53,
> var56, var59 ......var107 etc...are renamed as year1990,
> year1991......year2008 repectively. I tried to use renvars(by Jeroen
> Weesie) and a forvalues loop, but am not able to succeed.
> Is there any other way?
> Thanks and regards
> Abhimanyu
>
> PS-my incorrect way follows
>
>
> forvalues j =53(3)107{
> forvalues i =1990/2008{
> renvars postsub(`i',`j')    /*the arguments should be strings, I guess,
> though*/
> }
> }
> *
> *   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/
>

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