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

st: mata: evaluating strings and functions as arguments?


From   Matissa Hollister <[email protected]>
To   [email protected]
Subject   st: mata: evaluating strings and functions as arguments?
Date   Tue, 27 Dec 2005 09:28:04 -0800 (PST)

I have two quick questions about using mata:
1) is there a way to get mata to evaluate the content
of a string scalar, e.g.:

if I type:
b="4+5"

then I later type:
b
it returns
4+5

is there a way that I can get it to evaluate b, i.e.
return 9?

2) Is there an easy way to have a function be an
argument for another function?  Basically, I'd like to
define a function that allows for different methods
for calculating a value, so I'd like to be able to
specify as an argument for the function which
calculation function to use.  I could enter the
calculation function name as a string, and then
concatenate the arguments to the string.  Then I get
back to problem 1), how to get mata to execute the
concatenated string.

Thanks for the help.  I'm a very rudimentary stata
programmer so I apologize if I'm missing something
obvious.

MNH


	
		
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/
*
*   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