Some useful utility programs for Stata | Advice to doctoral students

Some useful utility programs for Stata

You’ll probably spend a lot of your time doing data management and statistical analysis (which you are doing in Stata, right?). So, small efficiencies in data related tasks can really pay-off in the long run. One way to get those efficiencies is through creating small utility programs that automate tasks that you perform many, many times.

It's very easy to write short programs for Stata. Below, I offer a few program, each only several lines in length, that I find really useful. Consider the dta command, which is saved as dta.ado in my "PERSONAL" directory (which you can find by typing sysdir at the Stata prompt. On the Mac, it is at ~/Library/Application Support/Stata/ado/personal/.)

program define dta
    ls *.dta
end

Now, I can just type dta at the Stata prompt and get a list of all the data files in the current working directory. Here are some other examples. Each should be saved as name-of-program.ado, e.g., the next one should be saved as ddo.do.

Same idea, lists all do files in the directory

program define ddo
   ls *.do
end

Quick way to open the current working directory in the Finder. Makes it easy to get to related non-Stata files quickly. (May need to be different for non-Mac systems)

program define oo
    !open
end