| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: how to use macro `using' in a program which calls for matafunction
From |
Oleksandr Shepotylo <[email protected]> |
To |
[email protected] |
Subject |
Re: st: how to use macro `using' in a program which calls for matafunction |
Date |
Wed, 10 May 2006 15:23:39 -0400 |
I have found mistake myself!
I should use
syntax [varlist] [using/]
Oleksandr Shepotylo wrote:
Hi Satalist users,
I am writing a program that at some point call for mata function:
mata:
void spatlag(string scalar varname, string scalar newvarname,
string scalar path)
{
real colvector x, y
st_addvar("float", newvarname)
st_view(x,., varname)
st_view(y,., newvarname)
fh = fopen(path, "r")
W=fgetmatrix(fh) y[.,.]=W*x
}
mata mosave spatlag(), dir(C:\ado) replace
end
It works fine when I type, for example
mata spatlag("var", "newvar", "C:\matrix1")
but it refuses to work if I use it in a program:
program define sptreg
syntax [varlist] [using]
...
mata spatlag ("var", "newvar", `"`using'"')
when I type
sptreg varlist using "C:\matrix1"
it gives an error message:
file using `"C:\weight"' not found
fopen(): 601 file not found
spatlag(): - function returned error
<istmt>: - function returned error
If I change my program by removing double quotes:
program define sptreg
syntax [varlist] [using]
...
mata spatlag ("var", "newvar", "`using'")
it returns another error message:
invalid expression
r(3000);
I guess that the whole problem is how to use quotes properly but I can
not find
mistake.
Thanks,
Oleksandr.
*
* 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/
*
* 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/