Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Variable name length limit
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Variable name length limit
Date
Tue, 20 Aug 2013 14:47:36 +0100
How far this bites depends on the number of variables.
You can specify your own names within -import excel-, but if you are
importing many variables that won't appeal.
Improving on Stata's name choice is no doubt possible, but not trivial
to achieve. You'd need the Excel header information. I imagine wildly
that Stata works on possible names from left to right, but that gives
poor answers whenever the truly diagnostic details occur towards the
end of a long descriptive label, say
Estimated regional GDP growth rate 1066-1485
Estimated regional GDP growth rate 1485-1776
Estimated regional GDP growth rate 1776-1812
Nick
[email protected]
On 20 August 2013 13:59, Jean Bouyer <[email protected]> wrote:
> 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 <[email protected]>
> Subject: Re: st: RE: Variable name length limit
>
> Thanks Nick! Very Helpful
>
> On Wed, Jun 19, 2013 at 3:47 PM, Nick Cox <[email protected]> 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
>> [email protected]
>>
>>
>> On 19 June 2013 08:02, James Bernard <[email protected]> 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/