Dear Statalist members,
I am running a do file for a dataset including a series of commands. It also includes multiple times of switching between Stata and Mata. Since I have to repeat the process for many datasets I created a while loop, looking something like this:
local i=2016
while `i'>=2003 {
local j=4
while `j'>=1 {
local j=`j'-1
}
local i=`i'-1
}
Normally exiting Mata of course is done with the command end. However, since I am switching within the while loop it errors. It gives error code r(1) - meaning I have hit the Break button. I however have not hit the Break button. The reason I believe the problem is with the command end within the while loop is because the error is given right after this end command. Moreover, the whole Do-file runs perfectly fine for one dataset without the while loop.
Any ideas how to solve this problem?
Thank you in advance,
Frank
I am running a do file for a dataset including a series of commands. It also includes multiple times of switching between Stata and Mata. Since I have to repeat the process for many datasets I created a while loop, looking something like this:
local i=2016
while `i'>=2003 {
local j=4
while `j'>=1 {
local j=`j'-1
}
local i=`i'-1
}
Normally exiting Mata of course is done with the command end. However, since I am switching within the while loop it errors. It gives error code r(1) - meaning I have hit the Break button. I however have not hit the Break button. The reason I believe the problem is with the command end within the while loop is because the error is given right after this end command. Moreover, the whole Do-file runs perfectly fine for one dataset without the while loop.
Any ideas how to solve this problem?
Thank you in advance,
Frank
Comment