Skip to content
Tutorials Center
My learning

Topics

Lesson 5 of 36 ยท Interface and Data

A Tour of the Stata Interface

Learn the Stata windows: Command, Results, History, Variables, Properties, Data Editor and Do-file Editor, plus the menus, preferences and keyboard shortcuts that save time.

The Stata window looks busy at first, but it is just a handful of panels, each with one job. Knowing what each panel shows will save you from hunting for results and variable names. This lesson describes the default layout of Stata for Windows and macOS (Linux differs slightly in appearance but has the same parts). We describe the screen in words, since the program is not available on this site.

The main windows

The five core windows

Command Type one command, press Enter
Results Output of every command
History Every command you ran
Variables Names and labels of the data

Properties shows details for the selected variable

1 / 2
  • Command window is a one-line box. You type a command and press Enter. Press the up arrow to bring back earlier commands.
  • Results window shows the output. Blue text is clickable (links to help, to sorted lists, to the previous command). Red text is an error message.
  • History window lists the commands from the session. Single click to copy one into the Command window; double click to run it again. Right-click to save selected lines into a do-file, which is a quick way to turn a session into a script.
  • Variables window lists the variables with their labels. Click a variable name to paste it into the Command window.
  • Properties window shows the variable's name, label, type, format, value label and notes, and the dataset's name, label and size. You can edit labels here.

The menu bar gives access to the same commands without typing:

Menu What it offers
File Open, Save, Import, Export, Log, Do..., Change working directory
Edit Copy table, copy as picture, Preferences
Data Describe, Create or change variables, Sort, Combine datasets, Variables manager
Graphics Graph builders for scatter, histogram, bar, box plots and more
Statistics Summaries, tables, linear models, panel data, time series, survey tools
User Custom menus you can add
Window Bring a window to the front, reset the layout
Help Search, PDF documentation, check for updates, Stata Journal

A very good trick: choose a command from a menu, fill in the dialog, and click OK. Stata prints the equivalent typed command in the Results window. You learn the syntax by reading what the menu generated, and you can paste it into a do-file. Dialogs also have a Submit button, which runs the command but keeps the dialog open so you can adjust options. The copy button at the lower left of many dialogs copies the generated command to the clipboard.

The Data Editor and Data Browser

edit opens the Data Editor, a spreadsheet-like view where you can type values. browse opens the Data Browser, the same view locked against changes. Prefer browse unless you really need to edit, because a typing slip in the editor changes your data silently.

STATA
browse                    // look only
browse price mpg if mpg > 25   // only some variables and rows
edit                      // can change values

Values typed in the editor are recorded in the Results window as commands (for example replace price = 4099 in 1), so the change is at least visible. Even so, make corrections in a do-file with replace rather than by hand, so the fix can be repeated. Colours in the Data Editor help: black cells are numeric, red are strings, and blue are labelled numeric values (with a value label attached; the underlying number is still a number).

The Do-file Editor

Open it with doedit or the toolbar icon. It is a text editor with syntax highlighting, line numbers and a Run button. Common shortcuts in recent versions:

  • Ctrl+D (Windows) / Cmd+Shift+D (macOS): run the selected lines, or the line with the cursor if nothing is selected.
  • Ctrl+R: run the selected lines quietly, with no output in the Results window.
  • The toolbar Execute (do) button runs the entire file.

Keep the Do-file Editor open all day. Type experiments in the Command window if you must, but move everything that works into the do-file.

Preferences you should set today

Open Edit > Preferences > General Preferences (on macOS: Stata > Settings). A few worth a minute:

  • Choose a font that makes 0 and O easy to tell apart (a monospace font such as Consolas or Menlo).
  • Results colour scheme: light, dark or classic.
  • Set set more off through preferences or in your do-files. The more prompt pauses long output with --more--; pausing is useless in scripts.
  • Graph preferences: the default scheme and size.
  • Save the layout with Window > Save Windows Preferences to keep your panel arrangement.
STATA
set more off, permanently   // stop the --more-- prompt for good
set linesize 100            // wrap output at 100 characters

Keyboard shortcuts for the Command window

Key Action
Up / Down arrow Cycle through earlier commands
Page Up Bring the previous command back from the Review list
Tab Auto-complete a variable name or command
Ctrl+8 Open the Data Editor
Ctrl+9 Open the Do-file Editor
Esc / Break button Stop a running command

Tab completion is worth building into your muscle memory: it prevents typos in long variable names. When you type mean and press Tab, Stata completes the unique name or shows the choices.

A small model of the History panel

The editor below is a stand-in for the History and Command windows: it records commands in order, and a command can be replayed or turned into a do-file. It does not run Stata; it demonstrates why history is useful.

Python Stand-in: turn a history into a do-file

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which window lists every command you have run in the session?

    History keeps the commands; Results shows the output.
  2. 2. Why is browse usually safer than edit?

    browse opens the data read-only, so you cannot change a value by accident.
  3. 3. You choose a command from a menu and press OK. What is a benefit?

    The command appears in Results, so you learn the syntax and can copy it into a do-file.
  4. 4. What does the --more-- prompt do?

    It pauses long output; set more off removes the pause, which scripts need.

Summary

  • The main panels are Command, Results, History, Variables and Properties.
  • Menus and dialogs generate commands you can copy into a do-file.
  • Use browse to look and edit only when you must change data by hand.
  • The Do-file Editor runs selected lines or the whole file and is where finished work belongs.
  • Set more off, a readable font and your preferred layout once.

Next: Working Directory and File Paths