Download STATA 11 for Windows SAMPLE SESSION

Transcript
Stata 11 Sample Session
Section 0 – File structure and Basic Operations for Stata 11
SECTION 0 - File structure and Basic Operations for Stata 11 .............................................................................................. 5
How Stata uses memory.......................................................................................................................................................... 6
The set memory command.................................................................................................................................................. 6
Increasing the amount of memory in the middle of a Stata session ...................................................................... 7
The drop _all command ................................................................................................................................................... 8
Types of files used by Stata and their extension names ............................................................................................... 8
Data files ................................................................................................................................................................................. 8
Log files ................................................................................................................................................................................... 8
The log using command ....................................................................................................................................................... 8
The cmdlog using command................................................................................................................................................ 9
The log close command ........................................................................................................................................................ 9
Do files ..................................................................................................................................................................................... 9
The doedit command ...................................................................................................................................................... 10
Discussion of the Windows used in STATA....................................................................................................................... 10
The Do-file Editor ............................................................................................................................................................... 11
The Data Editor Window ................................................................................................................................................... 12
The edit command........................................................................................................................................................... 12
Saving the Stata Data File ................................................................................................................................................ 15
The save, replace command......................................................................................................................................... 15
The Brower Window........................................................................................................................................................... 16
The browse command..................................................................................................................................................... 16
The Stata Results Window ................................................................................................................................................ 16
The Command Window...................................................................................................................................................... 16
The Viewer ........................................................................................................................................................................... 16
Stata Graph window ........................................................................................................................................................... 17
Summary of the Basic File Types ....................................................................................................................................... 17
SECTION 1 - Basic functions: Stata files, Descriptives and Data Transformations ............................................................ 18
Introduction.............................................................................................................................................................................. 18
Data files and the working file.............................................................................................................................................. 19
Working Directory ................................................................................................................................................................ 19
The cd command.............................................................................................................................................................. 19
Opening a data file .............................................................................................................................................................. 20
The use command............................................................................................................................................................ 20
Describing the contents of a data file ............................................................................................................................. 21
The describe command .................................................................................................................................................. 21
Data storage types.............................................................................................................................................................. 23
Display format...................................................................................................................................................................... 24
Labels ..................................................................................................................................................................................... 24
Documenting variables and labels...................................................................................................................................... 24
The labelbook command................................................................................................................................................ 24
–more– .................................................................................................................................................................................... 24
The label list command .................................................................................................................................................. 25
The codebook command ................................................................................................................................................ 25
Generating descriptive statistics........................................................................................................................................ 26
Descriptive statististics - using one variable ...................................................................................................................... 27
Descriptives.......................................................................................................................................................................... 27
The summarize command ............................................................................................................................................. 27
Information returned by Stata commands....................................................................................................................... 29
TABULATE - Frequencies .................................................................................................................................................. 30
The tab1 command.......................................................................................................................................................... 31
The histogram command ............................................................................................................................................... 31
Saving a graph to a file...................................................................................................................................................... 31
The list command ............................................................................................................................................................ 32
Descriptive Statistics - using two or more variables..................................................................................................... 36
Two-way Tables with Categorical Variables (Cross-tabulation)............................................................................. 36
The tabulate command .................................................................................................................................................. 37
Summary statistics on a continuous variable for each value in a categorical variable .................................. 39
The by ... sort: summarize command........................................................................................................................ 39
Data Transformations ............................................................................................................................................................ 41
Converting continuous variables to categorical variables........................................................................................... 41
The generate command ................................................................................................................................................. 41
The replace command .................................................................................................................................................... 42
The label variable command ........................................................................................................................................ 43
The label define command............................................................................................................................................ 44
The label values command............................................................................................................................................ 45
3