Bookmark and Share

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: too many macros


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: too many macros
Date   Thu, 30 Jun 2011 07:24:41 +0100

I'd use -set trace- to see exactly where the error occurs.

On a different note, there is no need to define these macros in a loop:

program myprog
syntax varlist
gettoken lhs rhs: varlist
tokenize "`rhs'"
...

Now the rhs variables collectively are in local macro -rhs- and
individually in macros -1- up.

On Thu, Jun 30, 2011 at 3:52 AM, Keith Dear <[email protected]> wrote:

> Is your program really called "prog"? That's not wise - you can define
> it, but how do you call it?
> Try a name that is not a reserved word (e.g. "myprog").
>
> That aside, I can't elicit that error message: your code works for me,
> even with 1000 rhs variables.
> Which version do you have? In Stata11, -help limits- does not mention
> any such limit, even for Small Stata.

> On 30 June 2011 12:01, ali hashemi <[email protected]> wrote:

>> Is there any limit on the number of macros that can be defined in a program?
>> I am using local macros to read the regressors in the varlist. Here is the
>> syntax:
>>
>> program prog
>> syntax varlist
>> local N: word count `varlist'
>> gettoken lhs rhs: varlist
>> forval i=1/`N' {
>>        local x`i' : word `i' of `rhs'
>>        }
>> ...
>> end
>>
>>
>> The above code works fine when the number of variables in the varlist is
>> less than 18. However, in my case I have at least 400 variables in the
>> varlist and I get this error message: "too many macros"
>>
>> Is there anything wrong with the above code that causes this problem? If
>> there is a limit for the number of macros defined in the program how can I
>> call the regressors in the varlist?

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index