Dear All,

just a quick question. Is it possible to use foreach within a mata function?

Suppose I have something lke:

Code:
mata:
foreach v of global regressors{
    D = 1 :/ W_`v'
    W_`v'2 =  editmissing(1 :/ (D:^2), 0)
}
end
I gen the following error message:

Code:
. mata:
------------------------------------------------- mata (type end to exit) -----------------------------------
: foreach v of global regressors{
'global' found where almost anything else expected
(3 lines skipped)
-------------------------------------------------------------------------------------------------------------
Is there any mistake in my code or is it not possible to include foreach in mata? If not, is there a way to work this around?

Thanks in advance.