Stata for Linux

Stata is a general purpose, statistical and matrix-oriented, data management package from StataCorp based in College Station, Texas.

Availability

Sociology maintains a 14-user, network Linux license for Stata SE (Special Edition), Version 10 on compute server verstehen. A Sociology LInux account is required for use.

Access Requirements

Windows users need the following:

Prior to opening a Stata session:

  1. Load X-Win32. This makes X-Window services available on your PC.
  2. Load F-Secure and open a termnal session to verstehen.soc.duke.edu.

Mac or Linux users:

Versions of Stata

The Sociology Stata installation includes two versions of Stata -- large data set Stata/SE and small data set Stata/IC. Their constraints are:

Constraint

Stata/SE

Stata/IC

Modification of Default

Default number of variables

5,000

2,047

set maxvar #

Maximum number of variables

32,766

2,047

Maximum string variable size

244

244

Default size of matrices

400 x 400

200 x 200

set matsize #

Maximum size of matrices

11,000 x 11,000

800 x 800

Default memory size

10MB

1MB

set memory # (where # may be #g, #m or #k)

Memory size is normally set to easily fit the size of data sets you are using, but not more than that. Remember this system is multi-user and is often being used by others simultaneously.

Invoking Stata

Stata for Linux has two user interfaces. The preferred is a graphical user interface termed Stata(GUI). The second is a nongraphical user interface termed Stata(console), which runs within an SSH terminal window. The following invocations are available from the terminal command line.

Invocation

Result

xstata &

Starts Stata/IC in Stata(GUI) mode and returns the terminal command line prompt

xstata-se &

Starts Stata/SE in Stata(GUI) mode and returns the terminal command line prompt

stata

Starts Stata/IC in Stata(console) mode

stata-se

Starts Stata/SE in Stata(console) mode

A Stata(GUI) session appears below. Commands are typed in the lower, right Command window. When Enter is pressed, the command is executed in the Results window. Output appears below the command. Submitted commands are listed in the Review window on the left. Clicking a command from Review pastes it into the command entry window, allowing easy reuse of commands. Variables associated with the data set currently in use are listed alphabetically in the Variables window on the left. Clicking a variable name also pastes it to the command window.

A Stata(console) session is shown below. The input prompt appears as a . (dot) at the bottom of the window. Commands are typed at the prompt and immediately executed after the Enter key is pressed. Results display below the command and a new prompt appears.

Getting Help

Stata provides a comprehesive help system, with links to internal help documents organized as mini-manuals on specific commands or topics. Help searches also provide links to Internet resources maintained by StataCorp and other major players in the Stata community.

Help through the Stata(GUI) entails these steps:

  1. Through the menus, select Help > Search....

  2. The subsequent Keyword Search box allows a search of official documentation help resources, net resources or both. Specify the scope of your search and enter one or more search keywords.

  3. Search results are presented in a Stata Viewer window. Browse through and explore links to items of interest. These may link in turn to other documents. If having multiple help documents open is useful, right-click on a link to display an option to Open Link in New Viewer.

  4. Use the Back button to return to the original search results or prior documents.

  5. Help results for some commands also provide dialog links in the upper, right corner that allow a menu-driven command entry. The command formed through dialog use displays in the Command window. This streamlines the process of learning command syntax.

A complete set of Stata 10 manuals is also found in the manual rack in the Sociology Computer Lab.

Session Logs

Stata sessions (program statements and output) from the Results window are saved to a file by turning on a log. To start a log, click the Log button in the Stata(GUI) and name the log file when prompted. Any work of importance should be logged and careful thought given to naming of log files.

Logs named without a file extension are given .smcl. This designates the default Stata Markup and Control Language format in which logs are saved. Standard SMCL logs give formatted print output.

Logs may also be saved in ASCII text format with a log session command. The example below starts the log file eval_step1.txt in ASCII format, as controlled by the text option placed at the end of the command.

Logging is ended by one of the following:

Logs are viewed and printed from the Stata Viewer. To open the viewer, select File > Log > View... If a log is currently open, it will be displayed in the viewer. Otherwise you are prompted for the name of the log to view or may browse to it.

A viewer can also be opened with a view command, as illustrated below.

Setting Default Network Printer

Stata logs from a viewer window or graphs from a graph window are usually printed to a department network printer. Set the default printer by entering one of the following commands before printing.

Command

Printer Selected

plab

Computer Lab printer (Room 135)

pcopy2

Copy Room printer (Room 258)

pcolor

Main Office color printer (Room 268)

Printing

The most typical method of printing is to right click in the viewer or graph window of interest and select the Print... option. A print dialog appears with many options for controlling the output format. Output goes to the network printer you designated above.

There are also command methods of printing. To print the entire contents of the Stata Results window, use:

To print a currently open Graph window, specify:


Computing Home | Sociology Home | Arts & Sciences Home | Duke Home