Taking Your Stata Programming Skills To The Next Level: Developing And Modifying Stata Ado Files

The objective of TStat Training’s more advanced course is to provide participants with the programming commands and options required to autonomously develop and modify Stata ADO files. The opening session offers a quick overview of the fundamental concepts and commands (macros, vectors, scalers, looping, branching, temporary objects, foreach, forvalues) intrinsic to successful programming development. Session two moves on to illustrate the most effective way to develop a Stata ADO file, introducing participants to more specific programming concepts (such as arguments, local subroutines and the temporary storing of results) and Stata’s programming commands tokenizemacro shift, marksample and markoutbyable and sortpreserve. In section three participants are introduced to Stata’s inbuilt matrix capabilities, before moving on in the final session to developing their own programs for linear and maximum likelihood estimators.


In common with TStat’s course philosophy, each session is composed of both a theoretical component (in which the programming techniques are fully explained via a series of course specific developed examples), and an applied (hands-on) segment, during which participants have the opportunity to implement the techniques under the watchful eye of the course tutor.


At the end of the course, it is expected that participants will be able to independently implement both the techniques learnt and personalize the ADO program templates specifically developed during the course in order to enhance the effectiveness of their research.

Researchers or professionals with a good knowledge of the introductory programming skills covered on our A Little bit of Programming goes an Awfully Long Way.. wising to take their programming skills to the next level in order to be able to program their only Stata ADO files for data analysis and data management and to develop Stata commands for least squares and maximum-likelihood estimators.

It is assumed that participants have a sound working knowledge of Stata and are familiar with the concepts and Stata commands treated in our introductory Stata Programming course: A Little bit of Programming goes an Awfully Long Way..


  1. Macros
    • Global macros
    • Local macros
  2. Scalars and matrices
  3. Temporary objects
  4. Looping
  5. Branching



  1. Programming in Stata
  2. Do-files and ADO-files
  3. Writing and modifying a Stata programs
  4. Programs without arguments
  5. Programs with positional arguments
  6. Programs with named positional arguments
  7. Storing and retrieving program results
  8. Programs with arguments using the “syntax” construct
  9. Using tokenize and macro shift
  10. ADO-files
  11. Implementing program options
  12. The return statements
  13. Sample restriction with marksample and markout
  14. Making a command “byable
  15. The use of sortpreserve
  16. Writing an rclass ADO-file
  17. Implementing program options
  18. Sample restrictions with marksample
  19. The usefulness of markout
  20. Make a program “byable
  21. The use of sortpreserve
  22. Writing an eclass ADO-file
  23. More on storing results in e()
  24. eclass program template
  25. Temporarily destroying the data in memory
  26. Local sub-routines



  1. Stata matrix commands
  2. Stata matrix input and output
  3. Matrix input from Stata estimation results
  4. Stata matrix subscripts and combining matrices
  5. Matrix operators
  6. Matrix functions
  7. Defining a macro by a matrix function
  8. Matrix accumulation commands



  1. Programming Linear Least Squares estimation
  2. Programming Maximum Likelihood estimation
  3. Some examples



We are currently adding the finishing touches to our 2024 training calendar. We therefore ask you to check our website regularly or contact us at should the dates for the course you are interested in not be published yet. You will then be contacted via email as soon as the dates are available.

Dr. Giovanni Cerulli
Research Institute on Sustainable Economic Growth
National Research Council of Italy – Rome


The objective of TStat Training’s more advanced course is to provide participants with the programming commands and options required to autonomously develop and modify Stata ADO files.