xstata8at the UNIX prompt. Three panes appear in a new window. Figure 1 shows an image of the Stata 8 window. You may customize the appearance of the window by clicking Prefs. For example, to change the color scheme from green on black in the "Stata Results" pane, click Prefs/General Preferences/Results. The editor is the bottom right pane. Type Stata commands here. Figure 2 shows a simple example. The upper left pane displays the Stata commands and commands that were entered in the lower right pane. The lower left pane lists the names of the variables, and the Stata Results window, upper right, displays the output. To show a high-resolution histogram, type, for example --
graph twoway scatter mpg weightThe result looks like --
print @Graphor by clicking the right mouse button on the plot and releasing on "Print Graph". You must be in a Stata full-screen session for the plot to display. But you can create a plot, print it, or export it to a file and use the Stata shell command to display it with a unix viewer such as ghostview or xv. Line Mode. To run a prompted Stata session but without the full-screen window, type --
stata8at the UNIX prompt. The Stata prompt is a period located at the beginning of the command line. To exit Stata, type --
. exitat the Stata prompt. If you have unsaved work in memory, Stata will refuse to exit. You can save your worksheet, then exit --
. save filename . exitreplacing filename with the name of your file. Stata adds an extension of .dta to your filename. Or you can force Stata to exit without saving your data by typing --
. exit, clearat the Stata prompt. You may enter data at the Stata prompt by typing the keyword "input" followed by a list of variable names. For example --
. input price mpg weight price mpg weight 1. 4697 25 1930 2. 8814 21 4060 3. 3667 . 2750 4. 4099 22 2930 5. end .To list the data, type list at the Stata prompt --
. list price mpg weight 1. 4697 25 1930 2. 8814 21 4060 3. 3667 . 2750 4. 4099 22 2930 .Variable names must --
. input 5. 5079 24 2280 6. 5189 20 3280 7. 8129 21 2750 8. end .List the cases again to confirm --
. list price mpg weight 1. 4697 25 1930 2. 8814 21 4060 3. 3667 . 2750 4. 4099 22 2930 5. 5079 24 2280 6. 5189 20 3280 7. 8129 21 2750 .To get univariate descriptive statistics type --
. summarize Variable | Obs Mean Std. Dev. Min Max ---------+----------------------------------------------------- price | 7 5667.714 1997.448 3667 8814 mpg | 6 22.16667 1.94079 20 25 weight | 7 2854.286 688.7878 1930 4060 .To record your session in a file, type --
. log using filenamesubstituting the name of your file for filename. The log file will be named filename.log. To stop recording commands and output in the log, type --
. log closeBatch Mode. You can run a Stata job with your commands in a command file instead of typing them interactively at the Stata prompt. Stata expects a filename extension of ".do" for its command files. For example, suppose a command file named mpgtest.do contains the following commands --
use mpgtest describeTo run Stata using this command file, type --
stata8 -b do mpgtestThe -b do flag indicates a batch run. The "do" keyword indicates to Stata to execute the commands in the file named after the do keyword, in this example, mpgtest.do. Stata assumes an extension of .do if you omit it. Output for this example is saved in a file called mpgtest.log. If your output is not written or not updated, check a file named stata.log for diagnostics. You can accomplish the same result by using the UNIX redirection symbols, like this --
stata8 < mpgtest.do >! mpgtest.logThe advantage of using the UNIX redirection symbols is that you have complete control over the names of your command files and output files. But the disadvantage is that you cannot set the command delimiter. The command to set the character that devides Stata commands is #delimit. This can be quite useful if you have commands that span more than one line, because it improves the readablity of your code. For example, to set it to the semicolon, put--
#delimit ;at the top of your command file. However, this command is ignored unless you run the batch command file using the -b do flag. To run the job in the background, use the UNIX "&" character at the end of the command. For example --
stata -b do mpgtest &Top
Help command: help command name. To get started with help, type help without a command name. Search command: search search topic
StataCorp. 2003, Stata User's Guide: Release 8, College Station, TX: Stata Corporation StataCorp. 2003, Stata Reference Manual: Release 8 (4 volumes), College Station, TX: Stata Corporation StataCorp. 2003, Stata Graphics Manual: Release 8, College Station, TX: Stata Corporation StataCorp. 2003, Stata Time-Series Reference Manual: Release 8, College Station, TX: Stata Corporation StataCorp. 2003, Stata Cross-Sectional Time-Series Reference Manual: Release 8, College Station, TX: Stata Corporation StataCorp. 2003, Survival Analysis and Epidemiological Tables: Release 8, College Station, TX: Stata Corporation StataCorp. 2003, Stata Cluster Analysis: Release 8, College Station, TX: Stata Corporation StataCorp. 2003, Getting Started with Stata for Unix, College Station, TX: Stata Corporation