07.02.2014 Views

Introduction to Stata 8 - (GRIPS

Introduction to Stata 8 - (GRIPS

Introduction to Stata 8 - (GRIPS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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<br />

No varlist: All variables<br />

summarize _all<br />

_all: all variables<br />

summarize sex age<br />

Two variables<br />

summarize sex-weight<br />

Variables in sequence<br />

summarize pro*<br />

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 />

by sex: 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)<br />

sometimes the same as _all<br />

_all<br />

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*<br />

all variables starting with pro<br />

13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!