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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Rename variables to reflect values? |

Date |
Fri, 5 Jun 2009 15:12:44 +0100 |

Without seeing exactly what you typed, further comment is difficult. But 1. I confirm that Roy's code is legal and correct. 2. I suggest that you check that all left and right quotes are present. Stata learners often don't notice that the left quote character is being used to open macro references. It may be one that you don't use very often, especially if you delegate to your word or text processor the task of working out which quotation marks to use. I can't see your keyboard, but on mine it is near the Tab key and some distance from most punctuation keys. This point is explained in [U] when local macros are introduced. 3. This code will only work for alphabetic a-z and integer characters. If the first value of a variable contains a decimal point, it won't work because they are not allowed in variable names. Nick n.j.cox@durham.ac.uk Victor, Jennifer Nicoll 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. Roy Wada sysuse auto, clear drop make headroom gear_ratio foreach var of varlist _all { ren `var' `var'`=`var'[1]' } Victor, Jennifer Nicoll > 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? * * 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/

**Follow-Ups**:**RE: st: Rename variables to reflect values?***From:*"Victor, Jennifer Nicoll" <jnvictor@pitt.edu>

**References**:**st: Rename variables to reflect values?***From:*"Victor, Jennifer Nicoll" <jnvictor@pitt.edu>

**RE: st: Rename variables to reflect values?***From:*Roy Wada <roywada@hotmail.com>

**RE: st: Rename variables to reflect values?***From:*"Victor, Jennifer Nicoll" <jnvictor@pitt.edu>

- Prev by Date:
**Re: st: RE: AW: Sample selection models under zero-truncated negative binomial models** - Next by Date:
**Re: st: creating a numeric matrix from string variables** - Previous by thread:
**RE: st: Rename variables to reflect values?** - Next by thread:
**RE: st: Rename variables to reflect values?** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |