Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Too many macros, but I create 1!


From   James Sams <sams.james@gmail.com>
To   statalist@hsphsun2.harvard.edu
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
sams.james@gmail.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index