[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Ward Vanlaar" <wardv@trafficinjuryresearch.com> |

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

Subject |
st: RE: Rename problem: r(110) already defined |

Date |
Tue, 12 Feb 2008 18:01:04 -0500 |

You can use -capture- and then something like: if _rc!=0 { exit } which will make the execution of your do-file stop. See also [P] -capture-. Ward -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Friedrich Huebler Sent: Tuesday, February 12, 2008 5:54 PM To: statalist@hsphsun2.harvard.edu Subject: st: Rename problem: r(110) already defined I am trying to convert all variable names in my data to lowercase, using the commands below. The -rename- command returns error code 110 "already defined" if a variable name is already lowercase. ds local vars "`r(varlist)'" foreach v of local vars { local newname = lower("`v'") rename `v' `newname' } The problem can be reproduced with the auto data. . sysuse auto . rename make make make already defined r(110); What is the rationale for disallowing -rename- in cases where there is no other variable by the same name? In theory, no two variables in my data have the same name, whether uppercase or lowercase. Can the commands above be modified without resorting to -capture-? I would like to avoid -capture rename- because if there are variables with the same name it indicates a problem with the data and execution of the do-file should stop at that point. Thanks, Friedrich * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Rename problem: r(110) already defined***From:*"Friedrich Huebler" <fhuebler@gmail.com>

- Prev by Date:
**st: Rename problem: r(110) already defined** - Next by Date:
**Re: st: Rename problem: r(110) already defined** - Previous by thread:
**st: Rename problem: r(110) already defined** - Next by thread:
**Re: st: Rename problem: r(110) already defined** - Index(es):

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