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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Too many macros, but I create 1!


From   James Sams <sams.james@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Too many macros, but I create 1!
Date   Thu, 06 Dec 2012 13:32:48 -0600

This is helpful. When i read the limits page, I presumed that the maximum 
macro length was a default. I see now that that is not the case. If the limits 
page had listed the defaults and linked how to change them, that would have 
been helpful to me in resolving this.

In any case, thank you for your guidance.

On Thursday 06,  December  2012 10:08:21 William Gould, StataCorp LP wrote:
> James Sams <sams.james@gmail.com> tried to create long macros -- about
> 400,000 characters long -- using a combination of Mata and Stata and
> ran into difficulty.
> 
> James is using Stata MP/8 12.
> 
> Daniel Klein <klein.daniel.81@gmail.com> replied, solving part of the
> 
> problem (I think).  He wrote:
> > Let me rewrite the code
> > 
> >       . mata: st_global("indexes", ///
> >       
> >               invtokens(strofreal(indexes = J(1, 1, (50000..111611)))))
> > 
> > (you could add a -st_rcclear()-)
> > 
> > Here the problem does not occur (though the contents are truncated
> > at 165000+ characters, as I am running Stata IC). I suspect your
> > problem has something to do with the maximum length of characters
> > allowed in a (local) macro. Others might shed more light on the
> > topic.
> 
> I can help.
> 
> The current maximum length of macros can be obtained from c(macrolen):
> 
> 	. display c(macrolen)
> 	165200
> 
> I am running Stata/SE, but I would have seen the same result had I been
> running Stata/IC or Stata/MP.
> 
> However, in Stata/SE and STata/MP, maxvar is setable, and the maximum
> macro length is a function of maxvar.
> 
> For instance, if I were to type
> 
> 	. set maxvar 12116
> 
> 	. display c(macrolen)
> 	400028
> 
> Setting maxvar to 12116 would allow James to create macros containing
> up to 400,028 characters.
> 
> For Stata/SE and Stata/SE, macrolen is given by the formula
> 
> 	macrolen = 33*maxvar + 200
> 
> For Stata/SE and Stata/MP, maxvar defaults to 5,000 and, using -set maxvar-,
> you can set it to any number in the range 2,048 to 32,767:
> 
> 	macrolen = 33* 2,048 + 200 =    67,784   (minimum)
> 	           33* 5,000 + 200 =   165,200   (default)
>                    33*32,767 + 200 = 1,081,511   (maximum)
> 
> 
> The reason macrolen is linked to maxvr is that macros are commonly used
> to hold Stata variable names, and thus need to be able to hold all the
> variable names that could appear in the dataset.  Variable names are
> 32 characters long, they will have space between them, and then some
> extra was added.
> 
> -- Bill
> wgould@stata.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/
-- 
James Sams
773-315-0810
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