This article aims to familiarize the reader with Stata interface.
The Stata Interface
1. The Command Box: This is the box at the bottom of the window where you can type in your commands and press Enter to execute them.
2. Results Window: Right above the Command box is the results window. It displays the command entered followed by its respective results which includes all the analysis tables and output.
3. History Pane: On the very left of your window is a vertical panel that displays all the commands you have executed in that specific Stata window. Any errors are displayed in red. If you wish to rerun a previously entered command, simply click on it in the history pane and the command will appear in the command box. You can then either enter it as it is, or make minor changes and enter it.
Users can also select multiple commands from the history pane while holding down the Ctrl key on their keyboard and do any operation on them such as copying or sending them to a do-file.
4. Variable List: This pane can be found on the top right of the Stata window. This contains a list of all the variables and their respective labels. On top of this pane, there is also a search bar which comes in handy if we are working with datasets with a lot of variables. We can type the name or label of any variable we need to see and Stata will show a filtered list of variables that match the search keyword. The width of the variable column and label columns can also be adjusted manually.
Related Article: How to use Stata Do file? Tips and Tricks
5. Properties Pane: This is situated at the bottom right of the window. This displays the properties of whichever variable we have selected from the variable list. A variable can be selected by simply clicking on it once in the variable list. If we wish to make any changes to a variable’s properties, we can click on the small lock icon present at the top left of the Properties pane and edit the details accordingly.
6. Status Bar: At the very bottom of the Stata window is a bar that displays the current working directory. This directory is where Stata looks towards when saving or importing data. This directory can be changed by following these steps: File -> Change Working Directory, and then choosing your desired location. Or it can also be changed using the command:
cd “directory path”
Performing Statistical Analysis
In order to perform statistical analysis on your data, you can adopt three different approaches.
- Menu: Stata has various menu options such as ‘Data’, ‘Graphics’, and ‘Statistics’ that can be used directly to run commands and statistical analysis on data.
- Command Box: Users can also type out relevant commands in Stata’s Command box and press Enter to run them.
- Do File: A more preferred and professional approach to working in Stata is writing commands in a do file.
Related Post: How to Add Comments in Stata Do File
Accessing Pre-Installed Datasets
Stata comes with some datasets that are preinstalled and ready for use when you install data. To get a list of all the datasets available, go to File -> Example Datasets -> “Example Datasets Installed With Stata”. Click on the ‘use’ option in front of the dataset name in the list in order to load it in memory. This will also generate a command in the Results window
You can also type this command yourself to load any dataset by following
sysuse with the dataset’s name. The command also appears in the History panel on the left in the Stata interface. This allows you to keep track of all the commands you have entered.
We can open a window that allows us to edit a dataset by typing the command
This window can also be opened by clicking on the eighth button in the tool bar below the menu bar.
edit command allows us to read and write data, the browse command only allows us to read the data. We cannot edit the data when in browse mode. Data can be browsed using the command:
Or its abbreviated form:
Menu Items: Data, Graphics, Statistics
Related Article: Stata Command Syntax: How To Write Commands in Stata
The most used menu options in Stata interface are Data, Graphics, and Statistics.
The Data menu item allows the user to perform data-specific operations like variable creation, data editing, combining datasets, sorting variables etc.
The Graphics menu item has options related to making graphs and charts.
The Statistics menu has a large variety of statistical operations that can be performed on data; from summarizing it to running regressions. For example, when we choose to summarize the data, a dialogue box opens where the variables to be summarized need to be selected. Clicking ‘Ok’ will execute the summarize command on the specified variables and close the dialogue box. Clicking ‘Submit’ will also execute the command and keep the dialogue box opened. This allows you to add or remove variables conveniently without having to open the dialogue box again.
On the bottom left of the dialogue box, there are three icons . The first option is the help option that opens up a help window which has more details on the specific command (its description, syntax, options, etc.). Users can read even more detail about the command by clicking on “View complete PDF manual entry” which opens up the relevant PDF document from Stata’s base reference manual.
The second option is the reset option which resets the dialogue box by clearing any existing inputs that the user previously entered. The third option copies the command to the clipboard. You can then paste it in a do file or the command box.
The buttons have the following function in order of their location:
The first button opens a new data file. The second button saves a data file. The third button is the print option. The fourth button is the log option which is used when creating SMCL files. The seventh button opens a new-do file . The eighth and ninth buttons are the data edit and browse options respectively. The tenth button opens up the variable manager.
The very last button with the icon of a cross is used to stop the execution of commands. This button appears red when Stata is in the process of executing a command (or a set of commands).