Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Funny macro behaviour inside a programme


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Funny macro behaviour inside a programme
Date   Fri, 5 Nov 2004 09:57:17 -0000

There was a while back a limit of 7 on the number of 
characters in a local macro name. Perhaps some earlier statement 
in your code is setting the -version- back 
so that limit bites. 

Nick 
[email protected] 

Mark Schaffer
 
> Hi everybody.  I've run into some funny behaviour by Stata 
> when dealing 
> with macros inside a programme.
> 
> Here's a snippet of a -trace-.  The programme calls -test-, 
> then displays 
> the results, then uses -tempname- to allocate some more local 
> names for 
> scalars.  It assigns a value to the new local `hpvalue', 
> which has been 
> given the local variable __00000O.  Not shown are two earlier 
> lines that 
> assigns values to previously-defined locals `hpvalue1' and 
> `hpvalue2'.  
> The last command asks Stata (8.2, btw) to display the values 
> of both of 
> these locals.
> 
> scalars:
>               r(drop) =  0
>               r(chi2) =  7.778333995775768
>                 r(df) =  1
>                  r(p) =  .0052876538356317
>   - tempname htest hpvalue hdf hsigma
>   - scalar `htest'=r(chi2)
>   = scalar __00000N=r(chi2)
>   - scalar `hpvalue'=r(p)
>   = scalar __00000O=r(p)
>   - di "hpvalue1=" `hpvalue' "  hpvalue2=" `hpvalue2'
>   = di "hpvalue1=" __00000O "  hpvalue2=" __00000O
> hpvalue1=.00528765  hpvalue2=.00528765
> 
> What is curious is that both `hpvalue1' and `hpvalue2' are 
> expanded to the 
> local variable that was assigned to `hpvalue', namely __00000O.
> 
> Eventually I got rid of the bug by using shorter local macro 
> names.  But 
> `hpvalue1', for example, has only 8 characters. Did I miss a 
> bit in the 
> manual that says that local macros have to have names with 
> fewer than 8 (!) characters?

*
*   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/



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