Archives for the Month of January, 2009

Section 10.6 in the User’s Guide

... is one paragraph at the bottom of page 80.
It tells you that you don't need to type the whole variable name. Just give it two-three letters, and hit the tab key. If you have variable names that have more than that many characters in common, Stata will fill out as much as it can [...]

Dummy variables

There are two straightforward ways to turn string variables into corresponding dummies -- also known as categorical variables -- using Stata. One is an extension of the tab command:

tab stringvar, gen(dummy)

Another makes use of the fact that you seldom need dummies for their own sake. Usually you want them used in some sort of regression [...]

Dealing with unhelpful .csv files

The easiest way to get your .csv (comma-separated values) text files into Stata is this:

insheet using myfile.csv, comma names

This assumes that your .csv file is well-behaved: names are on the first row, and any commas really are field separators.
This is sometimes not the case. Recently I got a set of .csv files that were likely [...]

Gems from the User’s Guide

A little over a year into my Stata 10 license, I can see some usage patterns over the two feet's worth of Stata documentation: Data Management and Programming are pretty well worn, the rest not so much. User's Guide,  [U], has been among the least popular, which is a pity, because chapter 18, Programming Stata, [...]

I’ve got Samba!

I finally got around to configuring the Samba server on the FreeBSD machine. The instructions are here and they couldn't be clearer. One thing didn't work the way the book described it, not big enough to be worth investigating. That's the syntax of Samba commands. Rather than

# smbpasswd -a username

I had to do

# /usr/local/bin/smbpasswd -a username

But [...]

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

Do-file rules — a justification

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