Hi All,
the issue is that I don't think Stata parser/compiler is able to do its job when a mata {block} is contained within a Stata {block}, such as -if {...}-, but also -forvalue {...}- etc.
Please try to run the following code and let me know why you think it behaves in such an unexpected way.
The problem is self-explained in the code:
Please note:
- I'm aware I could have terminated the mata block by using -end-, but this would not work when the block is nested in a Stata -forvalue- for example
- I'm aware I could have created a mata function and call it. However, long story short, please assume we want to insert a mata block {}, not a mata function
Many thanks.
PS: I have raised a similar problem in another thread, but I thought starting a new one would be a good idea, as I've now realised the issue is much wider/simpler and not as specific/complex as I initially thought it was in the other topic. So please let's consolidate the discussion here.
the issue is that I don't think Stata parser/compiler is able to do its job when a mata {block} is contained within a Stata {block}, such as -if {...}-, but also -forvalue {...}- etc.
Please try to run the following code and let me know why you think it behaves in such an unexpected way.
The problem is self-explained in the code:
Code:
local x = 1 if `x'!=1 { di "1) THIS message should not be displayed, and it is not" } if `x'!=1 { di "2) THIS message should not be displayed, and it is not" mata { 1000 } di "3) THIS message should not be displayed, but it is!" }
- I'm aware I could have terminated the mata block by using -end-, but this would not work when the block is nested in a Stata -forvalue- for example
- I'm aware I could have created a mata function and call it. However, long story short, please assume we want to insert a mata block {}, not a mata function
Many thanks.
PS: I have raised a similar problem in another thread, but I thought starting a new one would be a good idea, as I've now realised the issue is much wider/simpler and not as specific/complex as I initially thought it was in the other topic. So please let's consolidate the discussion here.
Comment