10.08.2013 Views

Introduction to Stata 8

Introduction to Stata 8

Introduction to Stata 8

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.

In commands that have a dependent variable, it is the first in the varlist:<br />

oneway bmi sex bmi is the dependent variable<br />

regression bmi sex age bmi is the dependent variable<br />

scatter weight height scatterplot, weight is y-axis<br />

tabulate expos case The first variable defines the rows<br />

Conditional commands. The if qualifier [U] 14.1.3.<br />

The opera<strong>to</strong>rs used in conditions are defined in section 10.1. Here are a few examples:<br />

summarize age if sex==1 statistics for males only<br />

list id age if age < 35 list only if age < 35<br />

replace npreg=. if sex==1 set npreg <strong>to</strong> missing for males<br />

Numeric ranges. [U] 14.1.4<br />

Numeric ranges are marked by a slash:<br />

recode age (1/9.999=1)(10/19.999=2) , generate(agegrp)<br />

list sex age weight in 1/10 // observations 1 <strong>to</strong> 10<br />

Number lists. The in qualifier [U] 14.1.8<br />

A number list (numlist) is a list of numbers; there are some shorthand possibilities:<br />

1(3)11 means 1 4 7 10<br />

1(1)4 4.5(0.5)6 means 1 2 3 4 4.5 5 5.5 6<br />

4 3 2 7(-1)1 means 4 3 2 7 6 5 4 3 2 1 (Danish CPR number test)<br />

1/5 means 1 2 3 4 5<br />

4/2 7/1 means 4 3 2 7 6 5 4 3 2 1 (Danish CPR number test)<br />

Example:<br />

list sex age weight in 1/10 // observations 1 <strong>to</strong> 10<br />

twoway line mort year , xlabel(1900(20)2000) // x-axis labels<br />

Weighting observations [U] 14.1.6, [U] 23.13<br />

A typical use is <strong>to</strong> 'multiply' observations when the input is tabular:<br />

Cases Controls<br />

Exposed 21 30<br />

Unexposed 23 100<br />

Total 44 130<br />

. input expos case pop // see section 8<br />

1 1 21<br />

1 0 30<br />

0 1 23<br />

0 0 100<br />

. end<br />

. tabulate expos case [fweight=pop] , chi2 // see section 11.1<br />

. cc expos case [fweight=pop] // see section 11.1<br />

14

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

Saved successfully!

Ooh no, something went wrong!