Announcement

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

  • How Can One Learn How to Write a User-Written Command Program?

    Dear Statalisters, Do you have any recommendations for how to learn to write a user-written program in Stata?

  • #2
    See Chistopher Baum's "An introduction to Stata programming": http://www.stata.com/bookstore/intro...a-programming/

    Comment


    • #3
      The answer to this will probably depend on the complexity of the programs you are thinking of.
      Of course, there is the manual, which has plenty of good examples: http://www.stata.com/manuals13/u18.pdf
      Some uni sites are a bit more easily readable and focus on more frequently used bits; e.g., http://data.princeton.edu/stata/programming.html or https://www.ssc.wisc.edu/sscc/pubs/stata_prog1.htm and https://www.ssc.wisc.edu/sscc/pubs/stata_prog2.htm

      Comment


      • #4
        Already the evident and excellent advice on what to read, [U] and Kit Baum's book.

        Here is a self-evaluation test to work out whether you are ready,

        1. You already have experience with using Stata interactively and solve most of your own little Stata problems quickly by yourself by examining your code carefully, looking at the help or reading manual entries.

        2. You understand the difference between a do-file tied to a specific dataset and a more general user-written program.

        3. You know the bad news: a single incorrect character could scupper your program absolutely. That doesn't put you off. You'll find that little thing.

        4. You know the good news: Stata is well documented and Statalist is supportive of serious coders.

        5. You already study other people's code for tips and tricks and look inside Stata's own code whenever you want to know how it works.

        6. You have some experience of programming or writing scripts in various software.

        7. You are clear that what you want to write deserves a program that no one else has written (better).

        There is no pass mark, but lots of Nos should be a warning.

        Comment


        • #5
          If you want to write your own estimation command (very few people do) also see

          http://www.stata.com/bookstore/maxim...imation-stata/
          -------------------------------------------
          Richard Williams, Notre Dame Dept of Sociology
          StataNow Version: 18.5 MP (2 processor)

          EMAIL: [email protected]
          WWW: https://www3.nd.edu/~rwilliam

          Comment


          • #6
            David Drukker from Stata corp. has recently written a series of posts on Stata programming with some emphasis on how to use Mata in ado-files.

            Comment


            • #7
              You may also want to check the Stata Blog for user written estimation commands as well (David Drukker has written a pretty thorough tutorial about this recently). The other suggestion I would make is to make extensive use of the viewsource command in Stata to look at the source for programs developed by others.

              Comment


              • #8
                Christophe Kolodziejczyk : Thanks! Excellent, indeed.

                To find your way through the series, here is a blog summarizing the first 20: http://blog.stata.com/2016/01/15/pro...osted-entries/

                Comment


                • #9
                  Dirk Enzmann : Thanks too. This link is more useful than mine . This post in the Stata blog is really great

                  Comment


                  • #10
                    for me, the best starting place was StataCorp written ado files; I then followed up in various documents (including many of those mentioned above) when I didn't fully understand what was going on; in addition, StataCorp runs netcourses; see, e.g., http://www.stata.com/netcourse/programming-intro-nc151/

                    Comment


                    • #11
                      I can say in full honestly that I found the net courses (151 and 152) extremely helpful for getting up and running with things relatively quickly and have used that bit of training to teach myself some other languages as well.

                      Comment


                      • #12
                        Thanks, All. That is very helpful advice!

                        Comment

                        Working...
                        X