Hi,
I am trying to make the code below work. However, I haven't been able to call the function I created for Mata in Stata. When I run this code, I get the following error message (regarding the last block of code):
centovintedias(): 3001 expected 1 arguments but received 0
<istmt>: - function returned error
In other words, I am trying to figure out how to call a mata function I wrote in stata. I don't know if the problem is the way I am calling f in the function or something else...
I am using Stata 13/MP.
I would be very pleased if you could help me! Thanks in advance!
I am trying to make the code below work. However, I haven't been able to call the function I created for Mata in Stata. When I run this code, I get the following error message (regarding the last block of code):
centovintedias(): 3001 expected 1 arguments but received 0
<istmt>: - function returned error
In other words, I am trying to figure out how to call a mata function I wrote in stata. I don't know if the problem is the way I am calling f in the function or something else...
I am using Stata 13/MP.
Code:
global VARALLL alll3_ret gasc3b_ret gasc4b_ret rlog3_ret vspt3_ret vspt4_ret global VARARCZ arcz3_ret fibr3_ret klbn3_ret klbn4_ret mlpa3_ret mspa3_ret mspa4_ret rpsa12_ret suzb11_ret suzb12_ret suzb3_ret suzb5_ret suzb6_ret global LISTAS "VARALL VARARCZ" mata function centovintedias(real scalar f) { A = J(131,1,.) h = 0 for (i=1; i<=131; i++) { if (h==0) A[i,1] = aux[i + datas_base[f,1] - 125,1] if (aux[i,1]==.) h = 1 if (h==1) { st_numscalar("limite", h) st_local("limite", strofreal(h)) return } } } end *THE PROBLEM HAPPENS WHEN I RUN THIS PART putmata datas_base global f = 1 foreach x of global LISTAS { local j = 1 foreach var of global `x' { gen aux = `var' putmata aux mata centovintedias(`f') mata: mata drop aux if limite==1 { mata: mata drop A } if j==1 { getmata principal = A, force } Else { getmata final`j' = A, force if _rc==111{ local j = `j' + 1 continue } } local j = `j' + 1 } global f = `f' + 1 }
Comment