I am attempting to write a Stata/Mata program which formats excel files using Mata, by looping over all .xlsx files in a specified directory. The first problem I have run in to is that Stata gives error message 199 "} is not a valid command name" when it reaches the end of the loop, after the "end" command for mata is processed. I'm assuming this is because Stata thinks "end" should close the program, however, I'm not sure what the solution is. The code is currently set up as follows:
Code:
prog formatxl args directory local list : dir "$root/`directory'" files "*.xlsx" foreach xlfile of local list { mata b = xl() b.load_book("`xlfile'") *formatting commands follow end } end
Thanks so much,
Nick Mahoney
0 Response to Using Mata*Inside Stata Program Loop
Post a Comment