Hello, everyone. I'm Zhang.

I would like to ask you a question about an 'End Duplicates' error in my mata programming.

My program is used to compute some matrixs. Considering the computing limit of stata, I need to use mata language. I wrote a do file for mata-stata interaface. I also want to use an ado programmingwhichmakes all kinds of do files run. But the problem is, in my program, the ado programming and the mata programming have the repeated same 'End'. Thus my stata report a error called ‘End Duplicates’.

So, I would like to ask you two questions.
First, is it wrong to write like this, and is stata not allowing this?
Second, if my idea is resaonable, how to code in order to interface mata programming with ado programming?


My codes are:
Code:
/*Define program*/                                                          

program define MYPROGRAM
version 14.0

/*Define syntax*/                                                          

syntax using/, [name(string)  *
                       [ ... ]   // some other options
            
use "`using'", clear   // import data
confirm name `name'

     /*Create and Compute Matrix use Mata*/                                                          

     mata:
      ...
      create a matrix named MATRIX
      ...

     /*End Mata*/
     end

/*End Program*/                  
end   // you can see that, there are two 'end's make 'end duplicates' and end unrecognize
Your answer is very important to me.
Thank you very much for your answer!