Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: RE: Variable name length limit |
Date | Tue, 20 Aug 2013 16:20:24 +0100 |
-renvars- (SJ) can make renaming easier, especially if you are on Stata <12. But here where the problem is very long names, you are still going to have do essentially all the thinking. People new to Stata 12 or 13 should look at -rename-. The only reason for sticking with -renvars- is if you remember its syntax and find it convenient. The authors never got any royalties, so won't be deprived by your switching to rename. Nick njcoxstata@gmail.com On 20 August 2013 16:04, Lachenbruch, Peter <Peter.Lachenbruch@oregonstate.edu> wrote: > will the renvars command help? > > Peter A. Lachenbruch, > Professor (retired) > ________________________________________ > From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] on behalf of Jean Bouyer [jean.bouyer@inserm.fr] > Sent: Tuesday, August 20, 2013 5:59 AM > To: Statalist Statalist > Subject: st: Variable name length limit > > I come back to an "old" post since I have a similar problem. > I have imported data into Stata from an Excel file. Initial variable names have been truncated to 32 characters when necessary. > I have had to use reshape wide that builds new variables adding number 1, 2, 3 ... at the end of the name. Therefore, some variables would have a name longer than 32 and the program returned an error. > I had to change one by one (I found no other way...) the name of the variables equal to 32. By the way, this was not so easy since the importation from Excel produced variable names with the same 31 first characters and a number in 32nd position. I agree that the Excel file could be better, but it was not mine ... > > Is there a better way to do ? > > Thanks > > Jean Bouyer > > > > Date: Wed, 19 Jun 2013 18:32:45 +0800 > From: James Bernard <jamesstatalist@gmail.com> > Subject: Re: st: RE: Variable name length limit > > Thanks Nick! Very Helpful > > On Wed, Jun 19, 2013 at 3:47 PM, Nick Cox <njcoxstata@gmail.com> wrote: >> Let's revise this description to fill in gaps and correct misstatements. >> >> 1. James is using -diff-, a user-written program from SSC. (Please >> remember to explain where user-written programs you refer to come >> from. Other posts show that failing to explain this just wastes other >> people's time, not a good thing to do when you want their help.) >> >> 2. From the code it appears that -diff- at various points may attempt >> to create scalars (not variables) with temporary names longer than >> Stata's limit, which Stata can't allow. >> >> There is no sense in which Stata can break its own limits. >> >> James alludes to discussions in September 2010 -- search >> http://www.stata.com/statalist/archive/2010-09/maillist.html -- but >> the nub of the matter is that the limit on scalar and variable names >> can't be disabled. >> >> This is arguably a bug, or limitation, in -diff-, but short of >> rewriting the program before the author does the only work-around for >> James is to use shorter variable names, say by >> >> clonevar copy1 = no_dynamic_boxes_fixedat_94 >> >> and feeding -copy1- and anything else problematic to -diff-.. >> >> Nick >> njcoxstata@gmail.com >> >> >> On 19 June 2013 08:02, James Bernard <jamesstatalist@gmail.com> wrote: >> >>> I have a variable named "no_dynamic_boxes_fixedat_94". After running a >>> t-test in -diff command (for Difference-in-Difference estimation) >>> Stata creates a variable named "_no_dynamic_boxes_fixedat_94_ttest_mc" >>> which has more than 32 characters.... >>> >>> it then returns error >> > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/