Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata command in Mata's loop

    As we know, we can run a Stata command in Mata as below:
    Code:
    mata:
    mata stata display "Hi!"
    end
    In my problem, I have to use a Stata command in Mata's for loop, however, I realized that a command like the above does not work:
    Code:
    mata:
    for (i = 1; i <= 10; i++) {
    mata stata display "Hi!"
    }
    end
    Specifically, it returns an error message "invalid expression".

    So, my question is that is there a way to run a Stata command in the loop?

  • #2
    Try instead the stata() Mata function.
    Code:
    mata:
    
    for (i = 1; i <= 10; i++) {
        stata(`"display "Hi!""')
    }
    
    end

    Comment


    • #3
      Joseph Coveney It works perfectly! Thank you so much!

      Comment

      Working...
      X