STATA: Access and Documentation

A. Colin Cameron, Dept. of Economics, Univ. of Calif. - Davis

This September 2005 help sheet gives information on


WHAT IS STATA

Stata is a regression package that is used particularly by biomedical and economics researchers using cross-section and panel data. It is becoming the most popular package for such purposes as it has many of the latest methods and is relatively easy to use.

For extensive information go to http://www.stata.com/
 

STATA ACCESS AT U.C.-DAVIS

- Stata is available on the Social Science Data Service (SSDS) Unix computer Palmer for faculty and graduate students in the Departments of Economics, Political Science and Sociology. You need an account on Palmer to access this. The license for Stata permits a limited number of users at anyone time. To date this has not been a problem.
- The Department of Economics lab and SSDS lab have Windows Stata running on PC.
- ARE also has STATA on both Unix and PC platforms.

STATA DOCUMENTATION

For details on obtaining information about Stata go to  sthelp.html

USING STATA ON A WINDOWS PC

For interactive use
start Stata by clicking on the Stata icon.

Simplest is in Windows Explorer to left double-click

For batch use with program in file myprog.do 
either
Using Windows Explorer left double-click on myprog.do
or
Start Stata by clicking on the Stata icon
In Stata change directory to the directory that has program myprog.do and data
e.g. cd c:\maindirectory\subdirectory
In Stata execute the program using the do command
e.g. do myprog.do

USING STATA ON A UNIX MACHINE

Telnet to the Unix machine (e.g. palmer.ucdavis.edu but this may change over time) and login

For interactive use give the command
   stata
and to quit give command
  exit, clear

For batch use with program in file myprog.do give the command
   stata -b do myprog.do
This will execute the commands in myprog.do and put output in myprog.log (and additionally to any log file that you specified in the program itself).

To make a batch file use the editor pico if it is available.
(This is easier to use that some of the other Unix editors. It is similar to pine).
A simple way to run Stata in batch mode is to run through a cycle of three commands:

     stata -b do myprog.do    Runs the Gauss program in batch mode
     pico myprog.log     Lets you see the results if they are in myfile.log
     pico myprog.do   Lets you edit and make changes to the Gauss program

You can use the up arrow key to save having to retype these commands.

As an intermediate approach while in interactive use of Stata one can
run a batch file with the Stata command rin.  For example, run myprog.do

Useful Unix commands include ls which lists the directory, cp to copy a file, and rm to remove a file.
 

SIMPLE EXAMPLE

The following example generates 100 draws from a normal distribution with mean 4 and standard deviation 2
and then gives a summary of the generated data.
  clear
  set obs 100
  gen normal24 = 4 + 2*invnorm(uniform(  ))
  sum
  exit, clear
 

For further information on how to use Stata go to
   http://cameron.econ.ucdavis.edu