Nov 8, 2011

Using Postfile in Stata (+2 examples)

Postfile can be used to generate new, computed datasets and to subset data into new datasets in Stata.

There is an awesome command in Stata you may not yet have heard of called postfile. It lets you create Stata datasets. It can be used for a variety of tasks:

  • For creating subsets of your data.
  • For building datasets of generated statistics.
  • For Monte Carlo-type experiments.

Nov 6, 2011

Using _n and _N in Stata

This article is all about using _n and _N in Stata. The functions mod() and round() are also covered at the end for your reference. They are particularly useful when using _n and _N

Nov 5, 2011

Using the Return List in Stata

Whether you are programming or trying to retrieve values calculated in Stata, your best bet is probably to use the return list command in Stata. For many of Stata's commands (particularly statistical ones), statistics generated or other data are saved in scalars, matrices, or macros. You may want access to this data for a variety of reasons:

  • To return more precise statistics, because Stata sometimes truncates values in output, but not in return values.
  • To reorganize data output to make it easier to read, copy, or interpret.
  • To build programs in Stata.

Nov 4, 2011

Common Stata Command Reference

Below you will find a neatly organized list of Stata Commands to explore. Type help followed by any of the following commands to reveal a helpfile on how to use them.

I have left a number of commands out - the ones I never find myself typing in (for instance, snapshot). This is a reference list, and a way for beginners to learn. It is not, however, comprehensive. Stata features excellent documentation, but I thought a concise list of commands would be quick and useful to some.

Nov 2, 2011

Four websites to start learning Stata

The following are four websites which can introduce you to Stata. Each covers the basics of Stata but they do not all cover the same things. I have used all four to learn a variety of different things in Stata.

  • UCLA Resources to Help you learn and use Stata - This site features tutorials for beginners, programs, teaching resources, code fragments, and more. Probably the best online resource outside of stata.com.
  • U. Wisc. Stata for Researchers - Introduction to Stata which quickly introduces programming functions.
  • Princeton Introduction to Stata - Introduction which includes a nice section on data management and a programming section.
  • Stanford Summer Programming Camp - This is an introduction but quickly moves into the programming side of Stata including programming with .ado files.

Nov 1, 2011

10 Things every Beginner should know about Stata

When I first started working with Stata my initial impression was that it was ugly, and overwhelming.  I was confused as to why you would want to type in commands rather than point and click (this became painfully obvious over time). This was because I had transitioned from Microsoft Excel. Of course, the two programs while sharing some functionality are hardly comparable.

What I have come to find is that the Stata and excel are built for different types of work. Excel is for data entry, simple data manipulation, and record keeping. Stata is for statistics, and statistical programming.

I should mention that I did not learn Stata starting from page one of the manual. Rather, I picked it up as I went along, through google searches, and using #1 from below.

I am by no means an expert - but having worked with Stata for over a year now I believe I've found a few things that I wish I could have discovered on my first week using Stata. Hopefully if your a beginner or intermediate Stata user, you'll find this list to be helpful! If your looking for a good place to start, I have highlighted four websites where you can start learning stata here.
  1. Type help followed by a command and Stata will bring up a help file or do a keyword search. For example, try typing in help correlate. This makes learning Stata easy and referencing proper usage of commands easier than using dialogues at times.