Introduction to Stata 8
Introduction to Stata 8
Introduction to Stata 8
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Numeric formats [U] 15.5.1<br />
The default is General format, presenting values as readable and precisely as possible. In most<br />
cases you need not bother with numeric formats, but you may specify:<br />
format dollars kroner %6.2f<br />
Format Formula Example 2 1,000 10,000,000<br />
General %w.dg %9.0g 1.414214 1000 1.00e+07<br />
Fixed %w.df %9.0f 1 1000 10000000<br />
%9.2f 1.41 1000.00 1.00e+07<br />
Exponential %w.de %10.3e 1.414e+00 1.000e+03 1.000e+07<br />
w: The <strong>to</strong>tal width, including period and decimals. d: Number of decimals<br />
You may use comma formats with <strong>Stata</strong>, but there are confusing limitations, and I don't<br />
recommend it. To display commas rather than periods (probably most relevant for graphs):<br />
set dp comma<br />
6.3. Missing values [U] 15.2.1<br />
Missing values are omitted from calculations. There are two types of missing values:<br />
The system missing value is shown as a . (period). It is created in input when a numeric field<br />
is empty; by invalid calculations, e.g. division by 0, or calculations involving a missing value.<br />
User-defined missing values are .a, .b, .c, ... .z . It is a good idea <strong>to</strong> use a general<br />
principle consistently, e.g.:<br />
.a Question not asked (complications <strong>to</strong> an operation not performed)<br />
.b Question asked, no response<br />
.c Response: Don't know<br />
Unfortunately no data entry program accepts .a in a numeric field. In EpiData you might<br />
choose the codes -1 <strong>to</strong> -3 (provided, of course, that they could not be valid codes) and let<br />
<strong>Stata</strong> recode them:<br />
recode _all (-1=.a)(-2=.b)(-3=.c)<br />
Missing values are high-end numbers; the ordering is:<br />
All valid numbers < . < .a < .b < ... < .z<br />
You need not bother about the actual numerical values behind the missing values, but you<br />
need <strong>to</strong> know the logics <strong>to</strong> avoid mistakes. In calculations missing values behave as expected,<br />
but not so in conditions. The following command initially surprised me by listing all whose<br />
age was > 65, and those with missing age:<br />
list age if age > 65<br />
To exclude the missing:<br />
list age if age > 65 & age < .<br />
To list the missing only, including the user-defined missing values:<br />
list id age if age >= . or<br />
list id age if missing(age)<br />
12