Archives for posts tagged ‘code recycling’

Do-file rules — one suggestion

I've gone through several iterations with my idea of best do-file practices, and I'm sure I'll go through some more before I retire. But right now, here's where I stand:
My do-files start with a handful of header commands that I found useful at various times. They might look something like this:

clear
set more off
set type double
set [...]

Qualify your commands with capture

Suppose you are assembling a .dta file from disparate pieces of raw data -- an .xls workbook here, a .txt file there -- that must each meet some specific conditions. If you do this in a do-file (as you should, for the sake of reproducibility) you will find it useful to first save each of [...]