Stata/Introduction


Why use Stata ?

edit
  • It includes the very latest methods in econometrics
  • It is a portable software (ie you can install it on your USB stick)
  • It is widely used in economics/econometrics.
  • It is commercial but it can utilize user-written functions.
  • It has a nice Graphical User Interface

Stata Basics

edit

Stata Windows

  • Command
  • Review
  • Variables
  • Variables Manager
  • Results
  • Data Editor
  • Data browser
  • Graph editor
  • Do-file editor

Main Windows

edit
  • All the results appears in the Results window.
  • The Command window can be used to interactively give instructions to Stata. This is an alternative to using the dialog boxes accessed via Stata drop-down menus or running Stata in batch mode using a do-file or ado-file.
  • The Variables window lists all variables and labels of the dataset in memory. You can click on the name of a variable and it appears in the command window.
  • The Variables Manager allows the user to quickly view and edit all the variable names, variable labels, formats, value labels, and notes.
  • The Review window shows a list of past instructions. It can be useful if you want to quickly do things again. You just have to click on an instruction and it will appear again in the command window.
  • You can also have a look at your data by typing in the command window -browse- or -edit-.
    • -edit- allow you to change your datasets by hand, exactly as in excel. However this is not recommanded.
    • -browse- may be a safer option. If you want to have a look at a specific list of variables, you can specify it to Stata by typing in the command window :
browse var1 var2 var3
  • The viewer window displays any SMCL (Stata Markup Control Language) file, such as help documentation.
  • The do-file editor allows users to create and edit do-files and ado-files.

Keyboard shortcuts

edit
  • Ctrl + D : do a program (selected text or whole do file)
  • ⌘ + Shift + D : do a program (Mac OS 10+)

Basic commands

edit
  • -help- (or -h-) : gives the help file of a command in a Viewer window.
h reg
  • -search- : search local help files for a keyword.
search covariance
  • -findit- : search a keyword across local and net-based files.
findit covariance
  • -cd- : change working directory
cd  "~/Desktop"
  • -pwd- : displays the print working directory.
pwd
  • -dir- or -ls- : list all the files in the working directory
ls /* Lists all files in the directory */
ls , w /* the 'w' option simplifies the output*/
ls *.dta, w /* lists all files ending with '''.dta''' */

Stata Do-files

edit

The command -doedit- opens a new do-file editor.

. doedit

Stata Programming Style

edit
  • Most command can be abbreviated. For instance:
    • g or gen stands for generate
    • h for help
    • su for summarize
    • gr for graph
    • sc for scatter
    • etc
  • No brackets
  • * at the beginning of a line stands for comment
  • Stata is case sensitive.

Updates, News, etc

edit
. view news
. news
. update
Index Next: Settings