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:
PC X-Window server software - we recommend X-Win32, distributed by OIT. Version 9 or above should be used. These versions provide TrueType font support, which greatly improves local rendering of Stata graphs.
An SSH client - we recommend F-Secure, distributed by OIT. When installing this product, make sure that X11 connections are tunneled.
Prior to opening a Stata session:
- Load X-Win32. This makes X-Window services available on your PC.
- Load F-Secure and open a termnal session to verstehen.soc.duke.edu.
Mac or Linux users:
SSH and X-Windows are native to these platforms. In either case, open a terminal window and start an SSH session to verstehen including the -Y option, which ensures proper operation of Stata in GUI mode.
$ ssh -Y verstehen.soc.duke.edu
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:
Through the menus, select Help > Search....
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.
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.
Use the Back button to return to the original search results or prior documents.
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.
. log using eval_step1.txt, text
Logging is ended by one of the following:
clicking the Log button and selecting the Close log file option
entering a log close command
- closing the Stata session.
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.
. view eval_step1.txt
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:
. print @Results
To print a currently open Graph window, specify:
. print @Graph

