Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Mata void functions and pointers

From   Matthew Baker <>
Subject   st: Mata void functions and pointers
Date   Thu, 17 May 2012 16:44:46 -0400

Dear listers:

     I have a problem in which I am trying to populate the elements of
a pointer with the results of a function. The problem is, the function
is void and returns its results through an argument, which makes
getting results into a pointer nontransparent. As a simple example,
consider the following:

/* Begin example */
clear all
void example(A,B,Ab) Ab=A*B
for (i=1;i<=3;i++) {

/* Display results */

for (i=1;i<=3;i++) {
/* end example */

One can see from the above that ALL the elements of the pointer
contain the results of the last operation performed by the "example"
function, as it perhaps should. I am curious if anyone has any ideas
as to how the pointer can be populated with the "right" results in
these sorts of cases.

Thanks in advance!

Matt Baker

Dr. Matthew J. Baker
Department of Economics
Hunter College and the Graduate Center, CUNY
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index