User’s Guide

Publisher: Stata Press
Copyright: 2023
ISBN-13: 978-1-59718-403-8
Pages: 397
Suggested citation

StataCorp. 2023. Stata 18 User’s Guide. College Station, TX: Stata Press.

Supplemental materials

Table of contents

Stata basics

1.1 Getting Started with Stata
1.2 The User’s Guide and the Reference manuals
1.2.1 PDF manuals
1.2.1.1 Video example
1.2.2 Example datasets
1.2.2.1 Video example
1.2.3 Cross-referencing
1.2.4 The index
1.2.5 The subject table of contents
1.2.6 Typography
1.2.7 Vignette
1.3 What’s new
1.4 References
3.1 Overview
3.2 Stata on the Internet (www.stata.com and other resources)
3.2.1 The Stata website (www.stata.com)
3.2.2 The Stata YouTube Channel
3.2.3 The Stata Blog: Not Elsewhere Classified
3.2.4 The Stata Forum
3.2.5 Stata on social media
3.2.6 Other Internet resources on Stata
3.3 Stata Press
3.4 The Stata Journal
3.5 Updating and adding features from the web
3.5.1 Official updates
3.5.2 Unofficial updates
3.6 Conferences and training
3.6.1 Conferences and users group meetings
3.6.2 NetCourses
3.6.3 Classroom training courses
3.6.4 Web-based training courses
3.6.5 On-site training courses
3.6.6 Webinars
3.7 Books and other support materials
3.7.1 For readers
3.7.2 For authors
3.7.3 For editors
3.7.4 For instructors
3.8 Technical support
3.8.1 Register your software
3.8.2 Before contacting technical support
3.8.3 Technical support by email
3.8.4 Technical support by phone
3.8.5 Comments and suggestions for our technical staff
3.9 References
4.1 Introduction
4.2 Getting started
4.3 help: Stata’s help system
4.4 Accessing PDF manuals from help entries
4.5 Searching
4.6 More on search
4.7 More on help
4.8 search: All the details
4.8.1 How search works
4.8.2 Author searches
4.8.3 Entry ID searches
4.8.4 FAQ searches
4.8.5 Return codes
4.9 net search: Searching net resources
5.1 StataNow
5.2 Platforms
5.3 Stata/MP, Stata/SE, or Stata/BE
5.3.1 Determining which version you own
5.3.2 Determining which version is installed
5.4 Size limits of Stata/MP, SE, and BE
5.5 Speed comparison of Stata/MP, SE, and BE
5.6 Feature comparison of Stata/MP, SE, and BE
6.1 Memory-size considerations
6.2 Compressing data
6.3 Setting maxvar
6.4 The memory command
6.5 Setting aside memory for temporary storage of preserved datasets
7.1 Description
7.2 set more
7.3 The more programming command
8.1 Making mistakes
8.1.1 Mistakes are forgiven
8.1.2 Mistakes stop user-written programs and do-files
8.1.3 Advanced programming to tolerate errors
8.2 The return message for obtaining command timings
9.1 Making Stata stop what it is doing
9.2 Side effects of clicking on Break
9.3 Programming considerations
10.1 Description
10.2 F-keys
10.3 Editing keys in Stata
10.4 Editing keys in Stata for Unix(console)
10.5 Editing previous lines in Stata
10.6 Tab expansion of variable names

Elements of Stata

11.1 Overview
11.1.1 varlist
11.1.2 by varlist:
11.1.3 if exp
11.1.4 in range
11.1.5 =exp
11.1.6 weight
11.1.7 options
11.1.8 numlist
11.1.9 datelist
11.1.10 Prefix commands
11.2 Abbreviation rules
11.2.1 Command abbreviation
11.2.2 Option abbreviation
11.2.3 Variable-name abbreviation
11.2.4 Abbreviations for programmers
11.3 Naming conventions
11.4 varname and varlists
11.4.1 Lists of existing variables
11.4.2 Lists of new variables
11.4.3 Factor variables
11.4.3.1 Factor-variable operators
11.4.3.2 Base levels
11.4.3.3 Setting base levels permanently
11.4.3.4 Selecting levels
11.4.3.5 Applying operators to a group of variables
11.4.3.6 Using factor variables with time-series operators
11.4.3.7 Video examples
11.4.4 Time-series varlists
11.4.4.1 Video example
11.5 by varlist: construct
11.6 Filenaming conventions
11.6.1 A special note for Mac users
11.6.2 A shortcut to your home directory
11.7 References
12.1 Data and datasets
12.2 Numbers
12.2.1 Missing values
12.2.2 Numeric storage types
12.3 Dates and times
12.4 Strings
12.4.1 Overview
12.4.2 Handling Unicode strings
12.4.2.1 Unicode string functions
12.4.2.2 Displaying Unicode characters
12.4.2.3 Encodings
12.4.2.4 Locales in Unicode
12.4.2.5 Sorting strings containing Unicode characters
12.4.2.6 Advice for users of Stata 13 and earlier
12.4.3 Strings containing identifying data
12.4.4 Strings containing categorical data
12.4.5 Strings containing numeric data
12.4.6 String literals
12.4.7 str1–str2045 and str
12.4.8 strL
12.4.9 strL variables and duplicated values
12.4.10 strL variables and binary strings
12.4.11 strL variables and files
12.4.12 String display formats
12.4.13 How to see the full contents of a strL or a str# variable
12.4.14 Notes for programmers
12.5 Formats: Controlling how data are displayed
12.5.1 Numeric formats
12.5.2 European numeric formats
12.5.3 Date and time formats
12.5.4 String formats
12.6 Dataset, variable, and value labels
12.6.1 Dataset labels
12.6.2 Variable labels
12.6.3 Value labels
12.6.4 Labels in other languages
12.7 Notes attached to data
12.8 Characteristics
12.9 Data Editor and Variables Manager
12.10 Data frames
12.11 References
13.1 Overview
13.2 Operators
13.2.1 Arithmetic operators
13.2.2 String operators
13.2.3 Relational operators
13.2.4 Logical operators
13.2.5 Order of evaluation, all operators
13.3 Functions
13.4 System variables (_variables)
13.5 Accessing coefficients and standard errors
13.5.1 Single-equation models
13.5.2 Multiple-equation models
13.5.3 Factor variables and time-series operators
13.6 Accessing results from Stata commands
13.7 Explicit subscripting
13.7.1 Generating lags and leads
13.7.2 Subscripting within groups
13.8 Using the Expression Builder
13.9 Indicator values for levels of factor variables
13.10 Time-series operators
13.10.1 Generating lags, leads, and differences
13.10.2 Time-series operators and factor variables
13.10.3 Operators within groups
13.10.4 Video example
13.11 Label values
13.12 Precision and problems therein
13.13 References
14.1 Overview
14.1.1 Definition of a matrix
14.2 Row and column names
14.2.1 The purpose of row and column names
14.2.2 Two-part names
14.2.3 Setting row and column names
14.2.4 Obtaining row and column names
14.3 Vectors and scalars
14.4 Inputting matrices by hand
14.5 Accessing matrices created by Stata commands
14.6 Creating matrices by accumulating data
14.7 Matrix operators
14.8 Matrix functions
14.9 Subscripting
14.10 Using matrices in scalar expressions
14.11 Reference
15.1 Overview
15.1.1 Starting and closing logs
15.1.2 Appending to an existing log
15.1.3 Suspending and resuming logging
15.2 Placing comments in logs
15.3 Logging only what you type
15.4 The log-button alternative
15.5 Printing logs
15.6 Creating multiple log files for simultaneous use
16.1 Description
16.1.1 Version
16.1.2 Comments and blank lines in do-files
16.1.3 Long lines in do-files
16.1.4 Error handling in do-files
16.1.5 Logging the output of do-files
16.1.6 Preventing —more— conditions
16.2 Calling other do-files
16.3 Creating and running do-files
16.3.1 Creating and running do-files for Windows
16.3.2 Creating and running do-files for Mac
16.3.3 Creating and running do-files for Unix
16.4 Programming with do-files
16.4.1 Argument passing
16.4.2 Suppressing output
16.5 References
17.1 Description
17.2 What is an ado-file?
17.3 How can I tell if a command is built in or an ado-file?
17.4 How can I look at an ado-file?
17.5 Where does Stata look for ado-files?
17.5.1 Where are the official ado-directory?
17.5.2 Where is my personal ado-directory?
17.6 How do I install an addition?
17.7 How do I add my own ado-files?
17.8 How do I install official updates?
17.9 How do I install updates to community-contributed additions?
17.10 Reference
18.1 Description
18.2 Relationship between a program and a do-file
18.3 Macros
18.3.1 Local macros
18.3.2 Global macros
18.3.3 The difference between local and global macros
18.3.4 Macros and expressions
18.3.5 Double quotes
18.3.6 Macro functions
18.3.7 Macro increment and decrement functions
18.3.8 Macro expressions
18.3.9 Advanced local macro manipulation
18.3.10 Advanced global macro manipultation
18.3.11 Constructing Windows filenames by using macros
18.3.12 Accessing system values
18.3.13 Referring to characteristics
18.4 Program arguments
18.4.1 Named positional arguments
18.4.2 Incrementing through positional arguments
18.4.3 Using macro shift
18.4.4 Parsing standard Stata syntax
18.4.5 Parsing immediate commands
18.4.6 Parsing nonstandard syntax
18.5 Scalars and matrices
18.6 Temporarily destroying the data in memory
18.7 Temporary objects
18.7.1 Temporary variables
18.7.2 Temporary scalars and matrices
18.7.3 Temporary files
18.7.4 Temporary frames
18.8 Accessing results calculated by other programs
18.9 Accessing results calculated by estimation commands
18.10 Storing results
18.10.1 Storing results in r()
18.10.2 Storing results in e()
18.10.3 Storing results in s()
18.11 Ado-files
18.11.1 Version
18.11.2 Comments and long lines in ado-files
18.11.3 Debugging ado-files
18.11.4 Local subroutines
18.11.5 Development of a sample ado-command
18.11.6 Writing help files
18.11.7 Programming dialog boxes
18.12 Tools for interacting with programs outside Stata and with other languages
18.13 A compendium of useful commands for programmers
18.14 References
19.1 Overview
19.1.1 Examples
19.1.2 A list of the immediate commands
19.2 The display command
19.3 The power command
20.1 All estimation commands work the same way
20.2 Standard syntax
20.3 Replaying prior results
20.4 Cataloging estimation results
20.5 Saving estimation results
20.6 Specification search tools
20.7 Specifying the estimation subsample
20.8 Specifying the width of confidence intervals
20.9 Formatting the coefficient table
20.10 Obtaining the variance–covariance matrix
20.11 Obtaining predicted values
20.11.1 Using predict
20.11.2 Making in-sample predictions
20.11.3 Making out-of-sample predictions
20.11.4 Obtaining standard errors, tests, and confidence intervals for predictions
20.12 Accessing estimated coefficients
20.13 Performing hypothesis tests on the coefficients
20.13.1 Linear tests
20.13.2 Using test
20.13.3 Likelihood-ratio tests
20.13.4 Nonlinear Wald tests
20.14 Obtaining linear combinations of coefficients
20.15 Obtaining nonlinear combinations of coefficients
20.16 Obtaining marginal means, adjusted predictions, and predictive margins
20.16.1 Obtaining estimated marginal means
20.16.2 Obtaining adjusted predictions
20.16.3 Obtaining predictive margins
20.17 Obtaining conditional and average marginal effects
20.17.1 Obtaining conditional marginal effects
20.17.2 Obtaining average marginal effects
20.18 Obtaining pairwise comparisons
20.19 Obtaining contrasts, tests of interactions, and main effects
20.20 Graphing margins, marginal effects, and contrasts
20.21 Dynamic forecasts and simulations
20.22 Obtaining robust variance estimates
20.22.1 Interpreting standard errors
20.22.2 Correlated errors: Cluster–robust standard errors
20.23 Obtaining scores
20.24 Weighted estimation
20.24.1 Frequency weights
20.24.2 Analytic weights
20.24.3 Sampling weights
20.24.4 Importance weights
20.25 A list of postestimation commands
20.26 References
21.1 Overview
21.2 The dynamic document commands
21.3 The putdocx, putpdf, and putexcel commands

Advice

22.1 Overview
22.2 Determining which method to use
22.2.1 Entering data interactively
22.2.2 Copying and pasting data
22.2.2.1 Video example
22.2.3 If the dataset is in binary format
22.2.4 If the data are simple
22.2.5 If the dataset is formatted and the formatting is significant
22.2.6 If there are no string variables
22.2.7 If all the string variables are enclosed in quotes
22.2.8 If the undelimited strings have no blanks
22.2.9 If you have EBCDIC data
22.2.10 If you make it to here
22.3 If you run out of memory
22.4 ODBC sources
22.5 JDBC sources
23.1 References
24.1 Description
24.2 Categorical string variables
24.3 Mistaken string variables
24.4 Complex strings
24.5 Reference
25.1 Overview
25.2 Inputting dates and times
25.3 Displaying dates and times
25.4 Typing dates and times (datetime literals)
25.5 Extracting components of dates and times
25.6 Converting between date and time values
25.7 Business dates and calendars
25.8 References
26.1 Continuous, categorical, and indicator variables
26.1.1 Converting continuous variables to indicator variables
26.1.2 Converting continuous variables to categorical variables
26.2 Estimation with factor variables
26.2.1 Including factor variables
26.2.2 Specifying base levels
26.2.3 Setting base levels permanently
26.2.4 Testing significance of a main effect
26.2.5 Specifying indicator (dummy) variables as factor variables
26.2.6 Including interactions
26.2.7 Testing significance of interactions
26.2.8 Including factorial specifications
26.2.9 Including squared terms and polynomials
26.2.10 Including interactions with continuous variables
26.2.11 Parentheses binding
26.2.12 Including indicators for single levels
26.2.13 Including subgroups of levels
26.2.14 Combining factor variables and time-series operators
26.2.15 Treatment of empty cells
26.3 References
27.1 Introduction
27.2 Means, proportions, and related statistics
27.3 Continuous outcomes
27.3.1 ANOVA and ANCOVA
27.3.2 Linear regression
27.3.3 Regression with heteroskedastic errors
27.3.4 Estimation with correlated errors
27.3.5 Regression with censored and truncated outcomes
27.3.6 Multiple-equation models
27.3.7 Stochastic frontier models
27.3.8 Nonlinear regression
27.3.9 Nonparametric regression
27.4 Binary outcomes
27.4.1 Logistic, probit, and complementary log–log regression
27.4.2 Conditional logistic regression
27.4.3 ROC analysis
27.5 Fractional outcomes
27.6 Ordinal outcomes
27.7 Categorical outcomes
27.8 Count outcomes
27.9 Generalized linear models
27.10 Choice models
27.10.1 Models for discrete choices
27.10.2 Models for rank-ordered alternatives
27.11 Exact estimators
27.12 Models with endogenous covariates
27.13 Models with endogenous sample selection
27.14 Time-series models
27.15 Panel-data models
27.15.1 Continuous outcomes with panel data
27.15.2 Censored outcomes with panel data
27.15.3 Discrete outcomes with panel data
27.15.4 Generalized linear models with panel data
27.15.5 Survival models with panel data
27.15.6 Dynamic and autoregressive panel-data models
27.15.7 Bayesian estimation
27.16 Multilevel mixed-effects models
27.17 Survival analysis models
27.18 Meta-analysis
27.19 Spatial autoregressive models
27.20 Causal inference
27.21 Pharmacokinetic data
27.22 Multivariate analysis
27.23 Maximum likelihood estimation
27.24 Generalized method of moments (GMM)
27.25 Structural equation modeling (SEM)
27.26 Latent class models
27.27 Finite mixture models(FMMs)
27.28 Item response theory (IRT)
27.29 Dynamic stochastic general equilibrium (DSGE) models
27.30 Lasso
27.31 Survey data
27.32 Multiple imputation
27.33 Power, precision, and sample-size analysis
27.33.1 Power and sample-size analysis
27.33.2 Precision and sample-size analysis
27.33.3 Group sequential designs
27.34 Bayesian analysis
27.35 Bayesian model averaging
27.36 References
29.1 Overview
29.2 Sharing datasets (and other files)
29.3 Official updates
29.3.1 Frequently asked questions about updating
29.4 Downloading and managing additions by users
29.4.1 Downloading files
29.4.2 Managing files
29.4.3 Finding files to download
29.4.4 Updating additions by users
29.4.5 Video example
29.5 Making your own download site