Finding and Installing User-Written Stata Programs

There are a tremendous number of user-written programs for Stata available which, once installed, act just like official Stata commands. Some are conveniences, like outreg for formatting regression output. Others calculate results Stata itself does not, such as polychoric for polychoric correlations. A few represent major extensions of Stata's capabilities, such as ice and mim for multiple imputation or gllamm for mixed models. Most of these programs are stored at Boston College's Statistical Software Components archive (or SSC, but not to be confused with the UW's Social Science Computing Cooperative or SSCC) .

You are welcome to install any user-written commands you desire to use, even in the labs, on Winstat or on the Linux servers, because Stata at the SSCC is set up to store the programs you install in your home directory. Thus you don't need to worry about programs you install causing problems for others. On the other hand, this means you need to install the user-written programs you want yourself. The SSCC does not try to identify some useful set of user-written programs and make them available to everyone.

This article will discuss finding, installing, and updating user-written programs. Fortunately Stata includes commands which make this very easy to do.

Finding User-Written Programs

If you know the name of the program you want to use, you can go directly to Installing User-Written Programs. However, it's much more common to know what you want to do without knowing what program (if any) can do it. This is a job for Stata's findit command.

For example, suppose you wanted to do something with Heckman selection models but don't know what command to use. Type:

findit heckman

The result is a tremendous amount of information. The findit command first searches Stata's official help files and notes that there is an official heckman command and several other related commands (this makes findit a powerful tool for figuring out how to do things in Stata in general, not just for finding user-written programs). It then searches Stata's web site and locates several FAQ entries, plus an example on UCLA's large statistics web site. It then begins to list relevant user-written programs, organized into "packages." Programs that were described in the Stata Journal or the older Stata Technical Bulletin are listed first.

You can click on each package to view a very brief description, including a list of files (one package may contain several related programs). Also note the (click here to install) link. Clicking on the .hlp file will get you the help entry for the program, which you can use to decide if the program will do what you need.

Installing User-Written Programs

If you know the name of the package you want to install, you can install it by typing

ssc install package

Alternatively, if you identified the package you want using findit you can install it by clicking on its (click here to install) link. However, avoid installing any package that is directly tied to an article in the Stata Journal or the Stata Technical Bulletin. These packages contain the program as it was described in the article and are not updated. Look for another package containing the program that is not tied to an article and, if one exists, install that instead.

For example, if you type

findit ice

the first three ice packages you'll see are (as of 4/30/2008) stb0067_1, stb0067_2 and stb0067_3, but none of these contain the latest version of ice. The package which does is simply called ice. As the author of ice (Patrick Royston) makes further changes and improvements, the ice package will be updated accordingly. If he writes another Stata Journal article describing the changes he has made the result will likely be an stb0067_4 package, but if you installed stb0067_3 you won't get the new version automatically.

(Getting the right version of ice is particularly important because multiply imputed data sets created by one version cannot be used by different versions--and the output of older versions can't be analyzed using mim at all. The newer versions of ice also include more capabilities than the older ones.)

Unfortunately, the ice package you want to install isn't trivial to find--it's about a third of the way through the very long list of results you get from findit ice. However, packages are usually named after the main ado file they contain, and that file is normally listed first in the package description. So if you've looked at stb0067_3 and decided that program will meet your needs, noting that ice.ado is the first file listed is enough to know that you can probably install the latest version by typing

ssc install ice

Updating User-Written Programs

While few user-written programs are updated as frequently as ice, it's still important to get the latest versions of any user-written programs you install. Sometimes updates will include important bug fixes, though the SSC archive has quality control measures in place to try to catch bugs before the program is distributed.

The easiest way to check that your user-written programs are up-to-date is to type:

adoupdate

The adoupdate command notes where each package was downloaded from and goes back to that location to see if a more recent version is available. If there is, you can install the latest version by typing:

adoupdate, update

You can get a list of the packages you've installed by typing:

ado dir

This can be very helpful for catching things like having downloaded stb0067_3 rather than ice. You can remove a package by typing

ado uninstall package

where package should be replaced by either the name of the package you want to remove or the number it is given by ado dir, including the brackets around it.

For example, suppose you downloaded some earlier version of ice that was associated with a Stata Journal article. Just typing

ssc install ice

will fail because you already have a copy of ice.ado and all the other related files, and the installer refuses to overwrite them. Thus you need to identify and remove the older version. To do so, type:

ado dir

If the results included the entry

[6] package st0067_3 from http://www.stata-journal.com/software/sj7-4
SJ7-4 st0067_3. Update: Multiple imputation of missing...

you could remove it by typing either

ado uninstall st0067_3

or

ado uninstall [6]

Then

ssc install ice

will successfully install the latest version. You should then type

adoupdate

periodically to ensure that ice stays up-to-date.

Last Revised: 4/30/2008