Liz's Stata Guide

Favorite New Command

recode

Tired of blocks of code like this?

gen x = 1 if y >= 0 & y <= 5;
replace x = 2 if y >= 6 & y <= 10;
replace x = . if y == . | y > 10;

Use recode instead! It can also be abused in many fun ways.

... more favorites

Latest Mistake

using if varx instead of
if varx == 1

if varx evaluates to TRUE if varx is missing, so if varx is a binary variable, your command will be executed for observations where varx is equal to 1 and where it's missing. This is probably not what you want.

... more mistakes

About

Welcome to my Stata guide! I first started putting this together when tutoring / teaching classes on statistics and econometrics for public policy while a grad student at the Woodrow Wilson School at Princeton. I'm continuing to update and expand it as my contribution to the internet.

I use Stata on an almost daily basis at work. Mostly what I do is pretty basic data manipulation and production of summary statistics. I don't use (and don't know) a lot of sophisticated statistical techniques, so the commands to implement them in Stata aren't included here. I do produce a fair number of graphics, and worry about how output is formatted, so this guide includes more on those topics than your average introduction to Stata.

If you find this page useful, please tell other people about it and link to it. Also, drop me a line at djiboliz@gmail.com with comments, suggestions or questions.

... more about this guide

First Ten Stata Commands

Get started using Stata with 10 simple but very useful commands.
  1. use
  2. describe
  3. tab
  4. sum
  5. tab, sum
  6. ttest
  7. reg
  8. gen and replace
  9. histogram
  10. scatter

Next Ten Stata Commands

Once you've mastered the basics, these commands will change your life.

Not yet written

  1. recode
  2. bys
  3. tabstat
  4. table
  5. egen
  6. areg
  7. graph hbar
  8. reshape
  9. foreach
  10. outsheet

Stata Command Guide

Examples

Additional examples of basic statistical concepts and how to implement them in Stata:

Notes

Brief notes on other useful Stata topics:

.ado Files

New commands that I have implemented using .ado files
  • aareg: fixed effects with multiple absorbed variables
  • dlogit: maginal effects from logit model
  • dind: difference in differences estimator
  • svyttest: T-test with survey data
  • and more

FAQ

Frequently asked questions

Not yet written

  • What's with the semi-colons?

contact: djiboliz@gmail.com
last modified: 21 Aug 2008