Header image: Architectural widgetsSociology at Duke
Navigation Bar: Resources

Research and Training

Sociological Sites

Computing Resources

Departmental Publications

University Libraries

Quick Links

  
 

Stata

Description: Stata is a general purpose, statistical package and matrix-oriented, data management programming language from the Stata Corporation, College Station, TX. Stata is finding increasing favor in the academic community because of good usability design, considerable statistical power, and the ability of advanced users to increase its capabilities through user-contributed extensions. Many new Stata users are able to perform useful work quickly.

Availability: Sociology maintains a 14-user, Special Edition Version 8, UNIX license on compute server paradigm. Perpetual licenses or annual student licenses for Windows Stata may be purchased with research or personal funds under the Stata GradPlan program, which is managed jointly by Stata Corporation and the OIT Site License Office.

Documentation: The complete Version 8 documentation set consists of:

  • Getting Started with Stata for UNIX
  • Stata User's Guide
  • Stata Graphics Reference Manual
  • Stata Programming Reference Manual
  • Stata Base Reference Manual [4 volume set]
  • Stata Time-Series Reference Manual
  • Stata Survival Analysis and Epidemiological Tables Reference Manual
  • Stata Cross-Sectional Time-Series Reference Manual
  • Stata Cluster Analysis Reference Manual
  • Stata Survey Data Refence Manual

A set of documentation is maintained in the Room 135 manual rack. The key manual is the Stata User's Guide, which provides an in-depth introduction, a basic reference section describing the elements of the language and a section on how to perform basic data management and statistical operations. The four-volume Stata Reference Manual, which is organized alphabetically by topic, covers complete details on base features. Specialized statistical analysis features are covered in a new series of method-specific manuals.

Additional Help and Information: The Stata page of the Social Sciences Computing site has pointers to additional web resources.

Modes of Usage Under UNIX: Stata is typically used in an interactive mode, of which there are two variants. A console mode of Stata is invoked by typing stata-se at the UNIX prompt. It is not possible to display graphs from within console mode of Stata. The basic programming interface is text-based and line-mode, as illustrated below in the opening screen:

The input prompt, as shown above, is a dot (.). Commands are typed at the prompt and immediately executed after the Enter key is pressed. Results are displayed below the command.

An alternate graphical mode is accessed by typing xstata-se at the UNIX prompt. This interface is similar to that of Stata for Windows. Use of this interface requires the prior loading into memory of a PC X-server, such as X-Win32. The figure below illustrates the appearance of the graphical interface.

Commands in the Stata GUI version are typed in the lower, right command window. When the Enter key is pressed, the command and any error messages or results are displayed in the "Results" window. The exit, clear command shown above closes the Stata session without requiring that the data stored in memory be saved. The command (to display a graph of "price" and "weight") results in a separate graph window as displayed below.

Session Printing and Logging: From within an interactive Stata session, there are two methods of output delivery. Output can be routed directly to a printer from the File menu or with a print command. Alternatively a session log can be run that records the session to a file, which can be printed after logging is terminated.

Before printing directly from a session, you must set a default network printer. Output may not be directed to local, desktop printers. Set the default printer by entering one of the following commands:

. pclus (selects the Room 135 cluster printer)

. pcopy2 (selects the Room 258 copy room printer)

. pcopy3 (selects the Room 330MR copy room printer)

Proximity and convenience will dictate the best printer to use. Once the printer is set, use either the File pulldown menu to print results and graphs or enter print comands in the command window. Typical commands are:

. print @Results (to print Results window content)

. print @Graph (to print Graph window content - the graph must be open)

This produces nicely formatted PostScript output to the designated printer.

Creating a permanent Stata session log requires the starting of a log file at the beginning of the session. For example, the commands:

. set logtype text

. log using st040112

define an ASCII text log type (as opposed to the "markup language" default) and initiate a log file called st040112.log named according to the date the session was run. The file is automatically closed when you exit Stata or earlier if you type the command:

. log close

The output contained in st010912.log can then be printed from within Stata with an embedded UNIX shell command preceded by an exclamation point (!), such as:

. !enscript -2r -Pclus st040112.log

or directly from the UNIX shell command prompt:

> enscript -2r -Pclus st040112.log

Either command produces 2-up printing - two pages per sheet printed in a landscape orientation - an efficient, paper-saving format.

Graphical output is saved by including an output file specification on the graphing command. The twoway scatter command below produces a scattergram and saves a Stata graphics file called pricewgt.gph, which can later be retrieved for viewing or editing.

. twoway scatter price weight, saving(pricewgt)


People Graduate Program Undergraduate Program Resources Home Duke University Home