Announcement

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

  • Stata coding standards/best practices/style guide?

    Coming into stata, I am having trouble finding the canonical Stata way to name variables, organize code, avoid pitfalls, handle errors in my functions, etc. Are there any coding standards or style guides that have been written up? (I am thinking along the lines of http://docs.python-guide.org/en/latest/writing/style/ or https://google.github.io/styleguide/cppguide.html )

    Obviously, reading the responses on this site is very valuable, but it would be nice to pass a link/document onto my RAs.

  • #2
    I wrote some thoughts down in http://www.stata-journal.com/sjpdf.h...iclenum=pr0018

    A meta-rule is to follow StataCorp's own conventions unless you have a good reason to the contrary.

    Comment


    • #3
      You can start with this Stata Journal article by Nick Cox. Kit Baum's Introduction to Stata Programming is also a good reference. You can also look at introductory books like this one

      Comment


      • #4
        Hello Jesse,

        There is also an on-going series of posts at The Stata Blog website about programming. It starts with basic concepts and then gradually advances to more advanced topics. Below is a link to the series:

        http://blog.stata.com/tag/stataprogramming/

        Comment


        • #5
          Thanks for all your responses, I will collect them. One thing I have had a great deal of trouble uncovering is the canonical way to generate errors in my internal programs when writing/testing code such as invalid parameters or preconditions. Also, is there any kind of library for unit testing?

          Comment


          • #6
            There isn't a library per se, but in the Stata community these are typically called certification scripts. A few people have tried putting together a Mata library for unit testing Mata source code but I'm not sure if it is still being developed/supported.

            Comment

            Working...
            X