Conventions and tips

General remarks

  • Minimum aim: computational reproducibility of your code
  • Better: Other people understand your data & code and can use it

Please note:

  • There are no universal guidelines for coding in Stata
  • What follows is a compilation of different guidelines & own experience
  • Most of the time, there is no “best solution”
  • No guarantee for completeness

These principles will also help yourself, because:
No one is perfect! Coding errors happen.

But with a good strategy, you can

  • Reduce errors while coding
  • Enable others to cross-check (“four eyes see more than two”)
  • Fix errors more easily

Some key principles

  • Code and data should be consistent
    → Agree on standards such as naming conventions within your team
  • Code and data should be as self-explanatory as possible & sufficiently commented/documented
    → Choose meaningful names for objects, comment workflow/decisions from the beginning
  • Code should be as simple & short as possible
    → Only keep what is needed, structure your code

Complete slide set of the following tabs