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]

st: Too many macros, but I create 1!


From   James Sams <[email protected]>
To   [email protected]
Subject   st: Too many macros, but I create 1!
Date   Wed, 05 Dec 2012 18:28:20 -0600

I have a program that drops into mata, generates a row vector, converts it to 
strings and then sends to stata as a macro. The macro it generates is about 
400,000 characters long, with about 62,000 individual entries, well within the 
limits of stata-12 mp 8 core edition. Here is some test code that shows what 
is going on and mimics the attributes of my data.

program test_case, rclass
    mata {
        indexes = 50000
        for (i=1; i<=61611; i++) {
            indexes = indexes, i+indexes[1]
        }
        cols(indexes)
        indexes = strofreal(indexes)
        indexes = invtokens(indexes)
        strlen(indexes)
        st_local("indexes", indexes)
    }
    return local indexes `indexes'
end

And when I run it:


. test_case
  61612
  381283
too many macros
r(920);

I'm certainly not generating too many macros. Either st_local or return is, as 
far as I can tell. Thoughts on what I should be doing?

-- 
James Sams
[email protected]
*
*   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/


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