04.06.2013 Views

Introduction to Stata 8 - (GRIPS

Introduction to Stata 8 - (GRIPS

Introduction to Stata 8 - (GRIPS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6. Variables<br />

A <strong>Stata</strong> data set is rectangular; here is one with five observations and four variables:<br />

Observations<br />

Variables<br />

obsno age height weight<br />

1 27 178 74<br />

2 54 166 67<br />

3 63 173 85<br />

4 36 182 81<br />

5 57 165 90<br />

6.1. Variable names<br />

Variable names can be 1-32 characters, but <strong>Stata</strong> often abbreviates long variable names in<br />

output, so I recommend <strong>to</strong> use only 8 characters. The letters a-z (but not æøå), the numbers<br />

0-9 and _ (underscore) are valid characters. Names must start with a letter (or an<br />

underscore, but this is discouraged because many <strong>Stata</strong>-generated variables start with an<br />

underscore). These are valid variable names:<br />

a q17 q_17 pregnant sex<br />

<strong>Stata</strong> is case-sensitive<br />

Variable names may include lowercase and uppercase letters, but <strong>Stata</strong> is case-sensitive: sex<br />

and Sex are two different variable names. Throughout this booklet I use lowercase variable<br />

names; anything else would be confusing.<br />

6.2. Numeric variables [U] 15.2<br />

Most often you don't need worry about numeric types, but if you encounter memory<br />

problems, you should know this (see section 15.1 on Memory considerations):<br />

Type Bytes Precision (digits) Range (approx.)<br />

Integer byte 1 2 ±100<br />

int 2 4 ±32,000<br />

long 4 9 ±2×10 9<br />

Floating point float 4 7 ±10 36<br />

double 8 16 ±10 308<br />

compress can reduce the size of your dataset considerably by finding the most economical<br />

way of s<strong>to</strong>rage.<br />

11

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

Saved successfully!

Ooh no, something went wrong!