Home

Introducing STATA

Working with Stata

When you open Stata, you’ll see five windows that contain:

An image of STATA at start

Commands in menus

In Stata many of the commands are available in menu form. As the menu is a complex web of branches and twigs you can soon ‘lose your way’ so we think it’s best avoided until you have some experience of Stata with the typed commands we show in this website.

Saving results

Although results show up on the screen, they don’t get saved onto your computer until you set up a log file which gives a permanent record of the analyses and can be can be reviewed, edited and/or printed later on. We strongly advise you to do this when you start doing any analyses. Log files can be set up in .txt format or in Stata code, .smcl. The .smcl format looks neater but can only be opened and printed within Stata whereas the .log format, though slightly less attractive, is easier to use afterwards.

A log file can be set up using the command: log using mphwork.log or by clicking on the ‘file’ button and moving down to ‘log’. Explore the menu to see the commands for stopping or suspending the log.

Opening datasets

This can be done using a command use data.dta where the dataset is already in Stata format (.dta) as here on this website. It can also be done using the ‘file’ button and clicking on ‘open’ etc, just as you’d do in other programmes. The data are stored in a spreadsheet format and can be reviewed by clicking on the ‘data editor’ button.

A note on graphs

It is worth mentioning that Stata isn’t as flexible with graphs as some other packages and it is not always easy to get a graph in the right format for reporting. But Stata does have a really nice graphic editor that works on graphs that are open. It is reasonably flexible and easy to use and so it can be quicker to produce a ‘basic’ graph and then edit it to make it nicer rather than figure out the commands needed to get the perfect graph to start with. Occasionally things are easier to do in other packages.

Most of the graphics here were rendered in black/gray and white. You can set that option by typing the command set scheme s1manual

Adding new commands

Stata has an active community of programmers adding new functionality. If you encounter a command that it does not know, check your spelling and if it is actually new you need to add a command type this command ssc install commandNameGoesHere

What if you get stuck?

Stata has an extensive in-built help system that provides help – eg help t test brings up a range of options that you might want to explore further by clicking on the links.