Stata commands

advertisement
Alphabetical list of common Stata commands
browse [varlist] [if
cd
exp]
Browse the data
directory
Change the current directory.
Note that you can use both slash (/) and backslash (\) under Windows, but only
slash (/) under Unix.
Put quotes around the full directory name if it contains spaces.
clear
Clears Stata memory. USE WITH CAUTION!
correlate [varlist] [if exp] [in range]
Computes the correlation between two or more variables based on the subset
of the observations that are available for all variables.
describe, [ short]
Shows size of the data set, the number of observations, the variables in the
data set, their types and labels
display exp
Evaluates an expression and outputs the result
drop varlist
Deletes specified variables from the current data set in memory.
drop [if exp] [in range]
Deletes specified observations from the current data set in memory.
egen [type] newvar = fcn(arguments) [if exp] [in range], [options]
Extensions to generate.
ereturn list
Shows the stored results of the previous estimation command
exit, [clear]
Exit Stata
clear option shows your understanding that it is OK to lose unsaved data.
generate [type] newvarname=exp [if exp] [in range]
Creates a new variable and set it equal to exp, and to missing otherwise
global gblname string
Creates a global macro gblname and copies string to it.
global gblname = exp
Creates a global macro gblname, evaluates exp and copies the result to
gblname.
The local macros are referred to as $gblname.
The ambiguities in the global macro names are resolved by putting { } where
needed.
graph box variable [if exp] [in range], [by(varlist) ]
Draws a box-and-whisker plot of the data
gsort [+|-variable] ...
Generalized sorting in both ascending and descending order
help command
Displays help on the specified command.
histogram variable [if exp] [in range] , [discrete width(#) bin(#)
start(#) density fraction frequency ...]
Draws a histogram for a single variable. Look through the help file for
relevant options.
infile
variables using filename, [clear]
Reads data from the raw text file. You can specify a dictionary for complex
tasks.
inspect variable [if exp] [in range]
Gives a small histogram, the number of values that are: unique; positive, zero,
negative; integer and non-integer; missing.
keep varlist
Keeps specified variables and deletes others from the current data set in
memory.
keep [if exp] [in range]
Keeps specified observations and deletes others from the current data set in
memory.
label variable [varname"text"
Gives a variable a label that is shown in the Variables window, in the output of
describe, tabulate, and in graphs
label define labelname # "text" ...
label values varname [labelname]
Defines a set of labelled values, and applies this set to the specified variable
list [variables] [if exp] [in range]
Shows the entries of the data set for the specified variables (for all variables by
default) and specified observations (all observations by default).
local lclname string
Creates a local macro lclname and copied string to it.
local lclname = exp
Creates a local macro lclname, evaluates exp and copies the result to lclname.
The local macros are referred to as `lclname'
log using filename
log close
Logs Stata output
set more [on|off]
Makes Stata stop and wait for user to press a key
varlist
Moves the specified variables to the front of the data set.
outfile [variables using] filename, [replace]
Writes the specified variables (or all of the data)
predict newvarname [if exp] [in range] , options
A universal post-estimation command to obtain observation level results of an
estimation procedure, such as fitted values and residuals for regress. The
supported options / statistics are provided in help files for the original
estimation commands.
pwcorr [varlist] [if exp] [in range] , [sig obs ...]
Computes pairwise correlations.
sig option requests significance of zero correlation testing
obs option requests the number of observations on which the correlation is
based
order
pwd
Displays the current directory.
recode [varlist] (rule) ..., generate(newvarlist)
Changes the values of numeric variables according to the specified rules.
rule is of the form
numlist | nonmissing | missing = #
regress depvar [varlist] [if exp] [in range], [robust cluster(varname)
...]
Estimates the linear regression of depvar on varlist.
robust and cluster options provide corrections of the estimates covariance
matrix
predict options: residuals for the residuals; xb for fitted values (default);
stdp for the standard error of the prediction; etc.
replace varname =exp [if exp] [in range]
Changes the entries of an existing variable
return list
Shows the results of a non-estimation command, if applicable
filename, [replace]
Saves the current data set in Stata format
scatter y-variable(s) x-variable [if exp] [in range], [formatting options]
Scatter plot of one variable against another, or several y-variables against one
x-variable.
The list of the formatting options is huge and will include options on the
marker shape, size and color, axes, space of the graph, title, and many other
things.
search phrase
Searches Stata help and online resources for phrase.
sort varlist
Sorts the observations in ascending order of variables in varlist
summarize [varlist] [if exp] in [range], [detail]
Descriptive statistics: means, medians, standard deviations, variances.
detail option gives percentiles, skewness and kurtosis.
table var2 [var2] [if exp] [in range] , [contents(...)] ...
Makes a table of summary statistics defined by contents, including
frequencies, means, counts, etc. of other variables by var1 or var1 and var2.
tabulate var2 [var2] [if exp] [in range ], [row column nolabel ... ]
One- and two-way frequency tables, with optional row and column
summaries/frequencies, and independence tests.
twoway plot [if exp] [in range], twoway options
Two way graphs, including scatter plots, line plots, bar plots, histograms, and
smoothing / trend line plots.
May be used as a wrapper to combine several scatter plots.
Options control axes, labels, title, legends, etc.
use filename
Loads the Stata data file into Stata memory
save
vif
Variance inflation factors
Download