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: On calling a mata-defined function in Stata


From   Dorothy Bridges <dbstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: On calling a mata-defined function in Stata
Date   Wed, 11 May 2011 07:19:15 -0700

I found in the archives the following comment regarding calling a
function in Stata: "or you can write a Mata function which you call
from Stata ... [which] is often more elegant."  I've tried
unsuccessfully to find instructions on how exactly to go about this.
What I'd like to do, I think, is:

Mata:
function f(x) return(x^2+2x)

In Stata
sca x=5
sca y=&f(x)

But, clearly, I don't know what I'm doing.  Many thanks in advance.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index