Introduction to Stata 8 - (GRIPS
Introduction to Stata 8 - (GRIPS
Introduction to Stata 8 - (GRIPS
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
7. Command syntax [U] 14.1<br />
<strong>Stata</strong> is case-sensitive, and all <strong>Stata</strong> commands are lowercase. Variable names may include<br />
lowercase and uppercase letters, but sex and Sex are two different variable names.<br />
Throughout this booklet I use lowercase variable names; anything else would be confusing.<br />
Uppercase variable names and are sometimes used within programs (ado-files, see section<br />
15.7) <strong>to</strong> avoid confusion with the variable names in the data set.<br />
The general syntax of <strong>Stata</strong> commands can be written like this:<br />
[prefix:] command [varlist][if expression][in range][weight][, options]<br />
Qualifiers and options<br />
Qualifiers are general <strong>to</strong> many commands. See below on if, in and weights.<br />
Options are specific <strong>to</strong> a command. A comma precedes the option list. Missing or misplacing<br />
a comma is a frequent cause of error messages.<br />
Command examples<br />
Here are examples with the command summarize (mean, minimum, maximum etc.):<br />
Prefix Command Varlist Qualifiers Options Comments<br />
summarize No varlist: All variables<br />
summarize _all _all: all variables<br />
by sex:<br />
summarize sex age Two variables<br />
summarize sex-weight Variables in sequence<br />
summarize pro* All variables starting with<br />
pro<br />
summarize age if sex==1 Males only<br />
summarize bmi in 1/10 First 10 observations<br />
summarize bmi [fweight=n] Weighted observations<br />
sort sex<br />
Separate table for each sex.<br />
summarize bmi<br />
Data must be sorted first.<br />
summarize bmi , detail Option: detail<br />
Variable lists [U] 14.1.1<br />
A variable list (varlist) calls one or more variables <strong>to</strong> be processed. Examples:<br />
(nothing) sometimes the same as _all<br />
_all all variables in the data set<br />
sex age pregnant three variables<br />
pregnant sex-weight pregnant and the consecutive variables sex <strong>to</strong> weight<br />
pro* all variables starting with pro<br />
13