Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Saving to locals in Mata


From   "Julian Reif" <[email protected]>
To   <[email protected]>
Subject   st: Saving to locals in Mata
Date   Wed, 25 Apr 2007 11:26:19 -0400

Hi,

I am having trouble saving to locals using Mata. The following ADO code demonstrates my problem:

***example.ado code***

	program example
		version 9.2

		mata: example()
	end

	mata:
		void example()
		{
			t = "string"
			st_local("my_local",t)
			stata(`" di "my_local is `my_local'""')
		}	
	end

***end example.ado code***

my_local is displayed as blank instead of "string". However, if I run the three lines of mata code inside of example() interactively, my_local has the contents "string". Why does this work interactively but not in my program? How should this have been coded so that it works?

The same problem happens if I use globals instead of locals.

Julian


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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