Statalist


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

RE: st: Rename variables to reflect values?


From   "Victor, Jennifer Nicoll" <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: Rename variables to reflect values?
Date   Fri, 5 Jun 2009 09:57:16 -0400

[Resending this message]
Roy, thanks for the suggestion.  However, I get a syntax error when I tried the procedure you suggested.  I thought I understood your logic, but I am not able to produce a renaming without an error.
-Jennifer

> 
> Does anyone have a suggestion for how I could rename my variables to 
> reflect the values in an observation or a variable? Or any other 
> suggested shortcuts, short of making this long local macro?
>
> Jennifer

sysuse auto, clear
drop make headroom gear_ratio
foreach var of varlist _all {
   ren `var' `var'`=`var'[1]'
}
 
Roy
 

*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index