Archives for the Month of September, 2008

Soup up your do-files: program

Most Stata commands are programs written in Stata's ado-file language; they are saved as .ado files that you are free to browse. For example, on my Windows XP machine the guts of the simple describe command are here: C:\Program Files\Stata10\ado\base\d\describe.ado. Stata will let you write your own ado-files and treat them as first-class citizens of [...]

Abstraction with macros

When professional programmers talk about abstraction they mean writing code that is not too context-specific. The goal of abstraction is platform-independent code. That has become synonymous with "runs on both UNIX and Windows" but platform need not mean operating system. PHP, for example, has a database abstraction layer called PEAR::DB whose job is to allow [...]

I just mucked up portupgrade

Since I run FreeBSD, once in a while I also run portaudit. Parenthesis: if I let some time go by between such exercises, portaudit will complain that the database is too old, but that's easy to fix with portaudit -F. Usually the console message is "0 problems found with your installed packages", but sometimes problems [...]

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 [...]

Edit Stata do-files with Notepad++

Notepad is nice, but you can do better. Notepad++ can highlight your syntax, help you match your parentheses and, coolest of all, fold your code. If you already program in some other language using some graphical IDE, you know what that means. If you don't, here: when you enclose slabs of your Stata do-files inside what Stata [...]

Encode uses and pitfalls

You won't always receive data saved in the most efficient format and there is no relief in sight. Bandwidth and hard drive sizes are growing unabated and making this only more likely, not less. It's common, for example, that data sets have string variables with a limited range of values. Suppose you have a file [...]

A way to handle runaway project scopes

The extended macro function dir will make Stata run whatever files it finds in a given directory. You don't have to enumerate those files. Sometimes that is useful. Say you start out with a simple idea, like running an OLS regression. And say your dependent variable and some of the regressors are in one file, [...]

Edit Stata do-files with Notepad

If you right-click on a do-file under Windows XP, you can either open it or edit it. Opening it means that Stata will launch and attempt to execute it. The editing, by default, will also trigger a Stata launch, under the assumption that you want to edit the do-file inside Stata's own do-file editor. That [...]

Key files for OpenSSH

My home server runs FreeBSD 7.0. I administer it from my Windows XP laptop, in the air-conditioned comfort of my home office, over wi-fi. The server runs OpenSSH. The laptop runs PuTTY. I wanted the added security of using SSH key files instead of password authentication. Google and the helpful bunch at the PC-BSD Forum [...]