There's apparently a programming principle going by the acronym DRY -- Don't Repeat Yourself. Somebody needs to teach it to Stata users.

See, Stata is so flexible and easy to use that it's perverse in a way. Take for example the ability to generate new variables on the fly, either in interactive mode or wherever in your do-file fancy strikes. You would, of course, use Stata's generate command, or your favorite short version of it, as in
 gen my_new_variable 
You couldn't do this in SAS. First, there's no such thing as interactive mode, and second, you'd have to be in the data step. SAS will impose a modular structure on your code, and if that's not your style, too bad. You'll find it awkward but you'll either have to live with it, or hire a SAS programmer. There is, by the way, such a job title. I just put "SAS programmer" in the search box at simplyhired.com and got 518 hits. And what did "Stata programmer" get me? This:

Dang. We didn't find anything for you.
We couldn't find any jobs for "Stata programmer".
You're probably a good speller, but check the keyword terms you entered.
You can also try using some other keywords, or enter fewer words to expand your search.
It's also possible we made an error somewhere.
Sometimes computers are human too... just shinier.

This might look like a digression, but it's not. Where I was going is this: robust, friendly, and well-designed tools like Stata make programmers out of all of us. That's the upside. The downside is that while we might be fine social scientists, or epidemiologists, or what have you, we'll be almost sure to be pretty lousy programmers, because ease of use breeds incompetence.

Back to DRY: if you can do anything at any point in your do-file, you will not resist repeating yourself, because that's the most expedient thing to do sometimes. Worse, you will do the same thing but with slight variations, like spelling 2 in one place and two'` in another. That will produce ugly, unmaintainable code.

Yet DRY is as feasible in Stata as in the least user-friendly of its alternatives (I'm not saying that's SAS, by the way; machine code might be worse). You just need to set up and keep some sensible rules of your own for what's acceptable when writing a do-file. I will follow up with some suggestions over the next couple of days.