2 The Stata user interface
The windows
This chapter introduces the core of Stata’s interface: its main windows, its toolbar, its menus, and
its dialogs.
Past commands appear here Results are displayed here Variable list appears here Data properties appear here
Current working directory Commands are typed here Current log status Command log status
appears here appears here appears here
After choosing the widescreen layout, we see an interface like the above. The five main windows
are the History, Results, Command, Variables, and Properties windows. Each window has its name
in its title bar. These five windows are typically in use the whole time Stata is open. There are other,
more specialized windows such as the Viewer, Data Editor, Variables Manager, Do-file Editor, Graph,
and Graph Editor windowsthese are discussed later in this manual.
To open any window or to reveal a window hidden by other windows, select the window from
the Window menu, or select the proper item from the toolbar. You can also use Mission Control to
reveal hidden windows, or use Command–` (left quote) to cycle through all open Stata windows.
Many of Stata’s windows have functionality that can be accessed by clicking on the right mouse
button (right-clicking) within the window. If your mouse has only one button, press the Control key
while pressing the mouse button to simulate a right-click. Right-clicking displays a contextual menu
that, depending on the window, allows you to copy text, set the preferences for the window, or print
the contents of the window. When you copy text or print, we recommend that you always right-click
on the window rather than use the menu bar or toolbar so that you can be sure of where and what
you are copying or printing.
1
2 [ GSM ] 2 The Stata user interface
The toolbar
This is the toolbar:
The toolbar contains buttons that provide quick access to Stata’s more commonly used features.
If you forget what a button does, hold the mouse pointer over the button for a moment, and a tooltip
will appear with a description of that button.
Buttons that include both an icon and an arrow display a menu if you hold down the mouse button.
Here is an overview of the toolbar buttons and their functions:
Log begins a new log or closes, suspends, or resumes the current log. See
[GSM] 16 Saving and printing results by using logs for an explanation of log
files. You can also choose a file to view in the Viewer.
Viewer opens the Viewer or brings a Viewer to the front of all other windows.
Click on the button to open a new Viewer tab. See [GSM] 3 Using the Viewer
for more information.
Graph brings the Graph window to the front of all other windows. Click on the
button to bring the topmost Graph window to the front. Click and hold to select
a graph to bring to the front. See The Graph button in [GSM] 14 Graphing
data for more information.
Do-file Editor opens the Do-file Editor or brings a Do-file Editor to the front
of all other windows. Click on the button to open a new Do-file Editor. Click
and hold to select a Do-file Editor tab to bring to the front. See [GSM] 13 Using
the Do-file Editor—automating Stata for more information.
Data Editor (Edit) opens the Data Editor or brings the Data Editor to the
front of the other Stata windows. See [GSM] 6 Using the Data Editor for
more information.
Data Editor (Browse) opens the Data Editor in browse mode. See Browse
mode in [GSM] 6 Using the Data Editor for more information.
More tells Stata to continue when it has paused in the middle of long output.
Click and hold to choose whether to run the command to completion. See
[GSM] B.5 More for more information.
Break stops the current task in Stata. See [GSM] 10 Listing data and basic
command syntax for more information.
Search Help Searches for help for both official and community-
contributed features. See [GSM] 4 Getting help for more in-
formation.
The Command window
Commands are submitted to Stata from the Command window. The Command window supports
basic text editing, copying and pasting, a command history, function-key mapping, filename completion,
and variable-name completion. The Command window also uses the same syntax highlighting as the
Do-file Editor. See [GSM] 13 Using the Do-file Editor—automating Stata for more information.
[ GSM ] 2 The Stata user interface 3
From the Command window, pressing
Page Up steps backward through the command history.
Page Down steps forward through the command history.
Tab autocompletes a partially typed variable name when possible or presents
a list of similar names if there could be more than one completion. Further
typing will narrow the list. As soon as the name is complete, the full name
will be inserted. If the name starts with a double quote, Tab attempts to
autocomplete a filename in the same manner.
See [U] 10 Keyboard use for more information about keyboard shortcuts for the Command window.
The command history allows you to recall a previously submitted command, edit it if you wish,
and then resubmit it. Commands submitted by Stata’s dialogs are also included in the command
history, so you can recall and submit a command without having to open the dialog again.
The Results window
The Results window contains all the commands and their textual results you have entered during
the Stata session.
You can scroll through the Results window to look at work you have done, it is much simpler to
search within the Results window by using the find bar. By default, the find bar is hidden. You can
toggle its visibility by clicking the Find button, in the Results window title bar.
You can clear out the Results window at any time by right-clicking in the Results window and
selecting Clear results from the contextual menu. This action is not undoable.
The Sidebar
The sidebar in the main window can have two or three tabs for controlling what it shows.
Variables shows the Variables and Properties windows.
History shows the History window when the window layout is set to Sidebar. When
the window layout is set to Widescreen, the History window is in its own pane on
the opposite side of the main Stata window.
Project Manager shows the Project Manager window.
By default, the Variables tab is active, showing the Variables and Properties windows. The
behavior of the Variables and History windows are explained below. For more information on the
Project Manager, see [P] Project Manager.
The Variables window
The Variables window shows the list of variables in the dataset, along with the properties of
the variables. By default, it shows all the variables and their variable labels. You can change what
properties get displayed by right-clicking on the header of any column of the Variables window.
Click once on a variable in the Variables window to select it. Multiple variables can be selected in
the usual fashion, either by Command -clicking on nonadjacent variables or by clicking on a variable
and Shift-clicking on a second variable to select all intervening variables.
4 [ GSM ] 2 The Stata user interface
Double-clicking on a variable in the Variables window puts the selected variable at the insertion
point in the Command window. If multiple variables are selected, double-clicking on any selected
variable will put all the selected variables at the insertion point in the Command window.
The leftmost column of the Variables window is called the one-click paste column. You can also
send variables to the Command window by hovering the mouse over the one-click paste column of
the Variables window and clicking on the arrow that appears.
The Variables window supports filtering and changing the display order of the variables. Text
entered in the entry field to the right of the magnifying glass will filter the variables appearing in
the Variables window. The filter is applied to all visible columns and shows all variables that match
the criteria in at least one column. By default, the filter will ignore case and show any variables
for which at least one column contains any of the words in the filter. Clicking on the arrow by the
magnifying glass will allow you to change this behavior.
You can change the display order of the variables in the Variables window by clicking on any
column header. The first click sorts in ascending order, the second click sorts in descending order,
and the third click puts the variables back in dataset order. Thus clicking on the Name column header
will make the Variables window display the variables in alphabetical order. Sorting in the Variables
window is live, so if you change a property of a variable when the Variables window is sorted by that
property, it will automatically move the variable to its proper location. Reordering the display order
of the variables in the Variables window does not affect the order of the variables in the dataset itself.
Right-clicking on a variable in the Variables window displays a menu from which you can select
Keep only variable varname (or Keep only selected variables if multiple variables are
selected) to keep just the selected variables in the dataset in memory. You will be asked for
confirmation. This affects only the dataset in memory, not the dataset as saved on your disk.
See [GSM] 12 Deleting variables and observations for more information.
Drop variable varname (or Drop selected variables if multiple variables are selected) to
drop, or eliminate, the selected variables from the dataset in memory. You will be asked for
confirmation. Just as above, this affects only the dataset in memory, not the dataset as saved
on your disk. See [GSM] 12 Deleting variables and observations for more information.
Copy varlist to copy the selected variable names to the clipboard.
Select all to select all variables in the dataset that satisfy the filter conditions. If no filter has
been specified, all variables will be selected.
Send varlist to Command window to send all selected variables to the Command window.
Preferences... to change the preferences for the Variables window.
Output compact varlist (e.g., v1-v4) toggles the preference for shortening the list of variables
by variable ranges in place of individual variable names.
Items from the contextual menu issue standard Stata commands, so working by right-clicking is just
like working directly in the Command window.
If you would like to hide the Variables window, grab the divider between the Variables window
and the Results window and drag it all the way to the right. This is like resizing the Variables window
to have zero width. Hiding the Variables window will also hide the Properties window.
To reveal a hidden Variables window, select Window > Variables.
The Properties window
The Properties window displays variable and dataset properties. If a single variable is selected
in the Variables window, its properties are displayed. If there are multiple variables selected in the
Variables window, the Properties window will display properties that are common across all selected
variables.
[ GSM ] 2 The Stata user interface 5
Clicking the lock icon in the Properties window title bar toggles the ability to alter properties of
the selected variables. By default, changes are not allowed. Once the properties are unlocked, you
can make any changes to variable or dataset properties you like. Each change you make will create
a command that appears in the Results and Command windows, as well as in any command log, so
the changes are reproducible. Using the Properties window is one of the simplest ways of managing
notes, changing variable and value labels, and changing display formats. See [D] notes, [D] label,
and [D] format.
Clicking the arrow buttons next to the lock icon will select the previous or next variable shown
in the Variables window, and that selection will be reflected in the Properties window. If you would
like to hide the Properties window, click on the disclosure control at the base of the Variables
window. If you would like to reveal a hidden Properties window, click on the disclosure control
at the base of the Variables window.
You should also investigate the Variables Manager, explained in [GSM] 7 Using the Variables
Manager, because it extends these capabilities and provides a good interface for managing variables.
The History window
The History window shows the history of commands that have been entered, with unsuccessful
commands and their error codes in red, by default. By default, the History window is on a tab in the
sidebar. You can show the History window by clicking on the History button, , in the sidebar.
At the base of the History window is a text entry field that filters the commands appearing in the
History window. By default, the filter ignores case and finds any commands containing any of the
words in the filter. Clicking on the arrow by the magnifying glass allows you to change this behavior.
You can hide the commands that produced an error by clicking on the arrow and selecting the Hide
Errors item from the list that appears.
To enter a command from the History window, you can
Click once on a past command to copy it to the Command window, replacing the contents of
the Command window.
Double-click on a past command to resubmit it. Executing the command adds the command to
the bottom of the History window.
Right-clicking on the History window displays a menu from which you can select various actions:
Cut removes the selected commands from the History window and places them on the Clipboard.
Copy copies the selected commands to the Clipboard.
Delete removes the selected commands from the History window.
Select all selects all the commands in the History window, including those before and after the
commands currently displayed.
Clear all clears out all the commands from the History window, including those before and
after the commands currently displayed.
Do selected submits all the selected commands and adds them to the bottom of the command
history. Stata will attempt to run all the selected commands, even those containing errors, and
will not stop even if a command causes an error.
Send selected to Do-file Editor places all the selected commands into a new Do-file Editor
window.
Save all... brings up a Save review contents dialog, which allows you to save all the commands
in the History window, including those before and after the commands currently displayed, in
a do-file. (See [GSM] 13 Using the Do-file Editor—automating Stata for more information on
do-files.)
6 [ GSM ] 2 The Stata user interface
Save selected... brings up a Save review contents dialog, which allows you to save the selected
commands in the History window in a do-file.
Preferences... allows you to edit the preferences for the History window.
If you would like to pull the History window into a sidebar on the left of the Results window so
that it is always visible, choose View > Layout > Widescreen. After you do this, you might need
to widen the main window so that your results will not wrap. Simply hover the pointer over the left
or right side of the window until it becomes a resizing symbol, and then drag outward.
To go back to having the History window in the sidebar, choose View > Layout > Sidebar.
Tabs
Most windows in Stata can have multiple tabs. If you drag a tab off the tab bar, it will create a
new window. You may drag a tab from any window and drop it on the tab bar of any other window
to move a tab from one window to another. If you do not see the tab bar on a window because the
window contains only one tab, you can select View > Show tab bar to make the tab bar visible.
By default, windows of the same type are tabbed together. So, for example, when you create a new
Do-file Editor, say, it will be put in a window with other Do-file Editors. If you click on the Create
new tab button, , a new tab of the same type as the active tab will be created, unless, of course, it
does not make sense to have a second tab of that type (such as the Results window). You can change
the order of the tabs by dragging the tabs along the tab bar within the window.
If you would like to change the behavior of the tabbing, select Stata > Preferences > General
preferences..., and select the Windows tab in the preference pane, and then select the type of window
whose tabbing behavior you would like to change.
Menus and dialogs
There are two ways by which you can tell Stata what you would like it to do: you can use menus
and dialogs, or you can use the Command window. When you worked through the sample session in
[GSM] 1 Introducing Stata—sample session, you saw that both ways have strengths. We will discuss
the menus and dialogs here.
[ GSM ] 2 The Stata user interface 7
Stata’s Data, Graphics, and Statistics menus provide point-and-click access to almost every
command in Stata. As you will learn, Stata is fully programmable, and Stata users can even create
their own dialogs and menus. The User menu provides a place for programmers to add their own
menu items. Initially, it contains only some empty submenus. As an example, suppose you wish
to perform a Poisson regression. You could type Stata’s poisson command, or you could select
Statistics > Count outcomes > Poisson regression, which would display this dialog:
This dialog provides access to all the functionality of Stata’s poisson command. Because the
dependent and independent variables must be numeric, you will find that the combo box will display
only numeric variables for choosing. The poisson command has many options that can be accessed
by clicking on the multiple tabs across the top of the dialog. The first time you use the dialog for a
command, it is a good idea to look at the contents of each tab so that you will know all the dialog’s
capabilities.
The dialogs for many commands have the by/if/in and Weights tabs. These provide access to
Stata’s commands and qualifiers for controlling the estimation sample and dealing with weighted data.
See [U] 11 Language syntax for more information on these features of Stata’s language.
The dialogs for most estimation commands have the Maximization tab for setting the maximization
options (see [R] Maximize). For example, you can specify the maximum number of iterations for the
optimizer.
8 [ GSM ] 2 The Stata user interface
Most dialogs in Stata provide the same six buttons you see at the bottom of the poisson dialog
above.
OK issues a Stata command based on how you have filled out the fields in
the dialog and then closes the dialog.
Cancel closes the dialog without doing anythingjust as clicking on the
dialog’s red close button does.
Submit issues a command just like OK but leaves the dialog on the screen so
that you can make changes and issue another command. This feature is handy
when, for example, you are learning a new command or putting together a
complicated graph.
Help provides access to Stata’s help system. Clicking on this button will
typically take you to the help file for the Stata command associated with the
dialog. Clicking on it here would take you to the poisson help file. The help
file will have tabs above groups of options to show which dialog tab contains
which options.
Reset resets the dialog to its default state. Each time you open a dialog, it
will remember how you last filled it out. If you wish to reset its fields to their
default values at any time, simply click on this button.
Copy command to Clipboard behaves much like the Submit button, but
rather than issuing a command, it copies the command to the Clipboard. The
command can then be pasted elsewhere (such as in the Do-file Editor).
The command issued by a dialog is submitted just as if you had typed it by hand. You can see
the command in the Results window and in the History window after it executes. Looking carefully
at the full command will help you learn Stata’s command syntax.
In addition to being able to access the dialogs for Stata commands through Stata’s menus, you
can also invoke them by using two other methods. You may know the name of a Stata command for
which you want to see a dialog, but you might not remember how to navigate to that command in
the menu system. Simply type db commandname to launch the dialog for commandname:
You will also find access to the dialog for a command in that command’s help file; see [GSM] 4 Getting
help for more details.
As you read this manual, we will present examples of Stata commands. You may type those
examples as presented, but you should also experiment with submitting those commands by using
their dialogs. Use the db command described above to quickly launch the dialog for any command
that you see in this manual.
[ GSM ] 2 The Stata user interface 9
The working directory
If you look at the screenshot on page 1, you will notice the status bar at the base of the main
Stata window that contains the name of the current working directory . This path indicates that
/Users/mydir/Documents is the current working directory. Each session, this is set to the working
directory you were using when you last quit Stata. The current working directory is the folder where
graphs and datasets will be saved when typing commands such as save filename. It does not affect
the behavior of menu-driven file actions such as File > Save or File > Open.... Once you have started
Stata, you can change the current working directory with the cd command. See [D] cd for full details.
Stata always displays the name of the current working directory so that it is easy to tell where your
graphs and datasets will be saved.
10 [ GSM ] 2 The Stata user interface
Stata, Stata Press, and Mata are registered trademarks of StataCorp LLC. Stata and
Stata Press are registered trademarks with the World Intellectual Property Organization
of the United Nations. StataNow and NetCourseNow are trademarks of StataCorp
LLC. Other brand and product names are registered trademarks or trademarks of their
respective companies. Copyright
c
19852023 StataCorp LLC, College Station, TX,
USA. All rights reserved.
®
For suggested citations, see the FAQ on citing Stata documentation.