Statalist The Stata Listserver

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

st: Mata function stata() within program

From   Ulrich Kohler <>
Subject   st: Mata function stata() within program
Date   Tue, 21 Mar 2006 16:57:16 +0100

I have a Mata function which looks as follows:



// Mata Function to extract the substitution costs from subcost-matrix
void showhash(real rowvector R)
	string scalar key1
	key1 = strofreal(R[1,2])
	stata("local hash1 = mod(`key1',197)")



The function is part of the mata-libary lsq.mlib, which compiles without 
problems. All other function in the library works well. However, if I run 
-showhash()- from within Mata I got the following error:

: R = 2,3,5,4
: showhash(R)
invalid syntax
                 stata():  3598  Stata returned error
              showhash():     -  function returned error
                 <istmt>:     -  function returned error

Further investigation showed that the error is connected to the -stata()- 
function. However, After running -showhash()- I can intactively run the same
-stata()- function without any problems:

: stata("local hash1 = mod(`key1',197)")
: stata("display `hash1'")

Any thoughts on this?


+49 (030) 25491-361
*   For searches and help try:

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