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

st: RE: new stata versions and local variable creation

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: new stata versions and local variable creation
Date   Mon, 11 Jul 2005 22:25:10 +0100

Replies below. 

[email protected] 

> (1) have there been changes between the different stata 
> versions (7,8,9) in terms of the size of 
> allowable matrices?  I.e. have they gotten larger or smaller 
> for allowable matsizes?

I think the limits have stayed the same since Stata 7 SE was introduced. 
                               Small        Intercoooled     SE    
matsize                          40            800         11,000

> (2) If you create local variables within an .ado file that 
> calls ANOTHER .ado file, do the locals 
> show up in the sub-file? 

Locals are local. What's more, if you know enough to
ask this question, you should know enough to answer 
it. If you go 

program parent 
	local governor "Terminator" 
	di "parent: `governor'"

program child 
	di "child: `governor'" 
	local governor "Good wine" 
	di "child: `governor'" 

what you find is

1. When -child- is called by -parent-, on the 
first -display-, the local 
macro `governor' is empty, as it has not been 
defined locally. The macro with _to you_ the 
same name in -parent- is not visible. 

2. On the second -display-, the macro has 
been defined locally and is now not empty. 

3. When control is passed back to -parent-, 
the previous definition of -governor- is 
the only definition visible. 

> On a similar note, how are they 
> destroyed if you are repeatedly calling 
> the sub-file?  I.e. suppose that you are in the file 
> "outer.ado" and you call "inner.ado" and 
> inner.ado creates the local "weird_var", then if I call 
> inner.ado 100 times, do I have 100 copies 
> of "weird_var" floating around as locals until the outer.ado 
> exits?  (I thought they should be 
> destroyed as soon as inner.ado completes, but I wanted to check.)

Precisely how they are destroyed is a matter of Stata's 
internal C code and not answerable by users. But I think 
you can safely presume that your local disappears when, or 
at least shortly after, its defining program terminates. 
My guess is that Stata monitors memory usage very closely 
and deletes junk pretty rapidly. 

*   For searches and help try:

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