STATA 7.0 Basics
The following page provides help on the most basic of STATA functions.
Please see the following for more detailed information:
- STATA Workshop on the StatLab Website (a good starting place for learning STATA)
- STATA FAQs on the StatLab Website
- Getting Started With STATA 7 (available for check out from the StatLab consultant)
The Windows version of STATA opens to present 4 "windows" and a task bar.
The black window window labeled "Stata Results" provides the screen for output.
The review box captures previous commands. The Variables window will list
all variables in your dataset. Finally the Stata Command window at the bottom
of the screen is where you will type in commands. This box is not available
when some other windows are open such as the data editor and viewer windows
. The Windows Menu on the task bar eases moving between windows.
While the Windows version of STATA gives you menu choices and buttons
for editing, viewing, and saving type tasks as well as help functions, for
the analysis you use STATA's command language.
All commands in STATA are entered in the CommandWindow.
- Starting & Stopping Stata
- To start click the STATA icon found under the Windows Start
Menu.
To quit STATA, select File > Exit or typeexit in the Command Window. If the workspace is not empty enter - exit ,clear
- Loading and Saving Data
-
- If the workspace in memory is not empty clear by entering
- clear
- Load STATA files, to open an existing STATA fileolddata.dta
- select File > Open or enter the command
-
- use c:\user\olddata
- Load ASCII files (sometimes called raw data file) , these files can most easily transfered into STATA by using the StatTransfer program
- (found under the Windows Start menu). StatTranfer will ask you for the type of file (generally .txt or .dat) and the name and location of the file (use the Browse button). For "Output File Type" select Stata (Standard Verion) 7. StatTransfer will automatically create a new file name based on the old file name. Simply press Transfer. Follow directions above for "Load Stata Files."
- Manual input, STATA 7.0 allows you to enter data as on a spreadsheet. Click on the
- Data Editor button. When you are finished entering
data, click on
Preserve to update contents of the editor window. - Save data in STATA format click on
- File > Save and fill in the name and path in the Save Window.
-
- Some Common Commands
-
- generate Age_Cat=1 if Age>65
- generates a new variable Age_Cat, which is set to 1, if variable Age is greater than 65, otherwise Age_Catis set to missing (coded by ".").
- replace Age_Cat=0 if Age<=65
- assigns 0 to the existing variable Age_Cat, if variable Age is less or equal to 65.
- list Age Age_Cat
- displays the values of the variables AgeandAge_Cat in tabular format.
- summarize Age
- computes descriptive statistics of variable Age
- tabulate Age
- creates a frequency table of Age
- Saving Character based Output for Printing or Later Review
- While output will appear in the "Stata Results Window" temporarily,
this output is not automatically saved. To ensure that you capture your output
use log files.
Click on the Log button to open a log file. This will open the Stata Log Window. From now on everything which appears theStata Results Window is also copied into the log file.
Also, at the end of your session click on the picture next to "Review" and select "Save Review Contents." This will provide you a record of all commands used (but not output). - Graphs
- graph variable_name opens aStata Graph Window
and displays a histogram of the variable.
To save the graph as a file, Click on File > Save Graph (Graph must be current window)
To print the graph, Click on File > Print Graph - Help in STATA
- You get on-line help by clicking Help in the menu. Type in keywords for a specific search, or click on Contentsbutton to browse topics.
- Other Resources
lm: 12/4/2002
