Introduction to Stata 8
Introduction to Stata 8
Introduction to Stata 8
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
9. Documentation commands [GSW] 8<br />
<strong>Stata</strong> does not need documentation commands; you need the documentation yourself. The<br />
output becomes more legible, and the risk of errors when interpreting the output is reduced.<br />
Data set label [U] 15.6.1; [R] label<br />
You can give a short description of your data, <strong>to</strong> be displayed every time you open (use) data.<br />
label data "Fertility data Denmark 1997-99. ver 2.5, 19.9.2002"<br />
It is wise <strong>to</strong> include the creation date, <strong>to</strong> ensure that you analyse the most recent version.<br />
Variable labels [U] 15.6.2; [R] label<br />
You can attach an explana<strong>to</strong>ry text <strong>to</strong> a variable name.<br />
label variable q6 "Ever itchy skin rash?"<br />
Use informative labels, but make them short; they are sometimes abbreviated in output.<br />
Value labels [U] 15.6.3; [R] label<br />
You can attach an explana<strong>to</strong>ry text <strong>to</strong> each code for a variable. This is a two-step procedure.<br />
First define the label (double quotes around text with embedded blanks):<br />
label define sexlbl 1 male 2 female 9 "sex unknown"<br />
Next associate the label sexlbl with the variable sex:<br />
label values sex sexlbl<br />
Use informative labels, but make them short; value labels are often abbreviated <strong>to</strong> 12<br />
characters in output.<br />
Most often you will use the same name for the variable and its label:<br />
label define sex 1 male 2 female<br />
label values sex sex<br />
but the separate definition of the label enables you <strong>to</strong> reuse it:<br />
label define yesno 1 yes 2 no<br />
label values q1 yesno<br />
label values q2 yesno<br />
If you want <strong>to</strong> correct a label definition or add new labels, use the modify option:<br />
label define sexlbl 9 "unknown sex" , modify<br />
adds the label for code 9 <strong>to</strong> the existing label definition.<br />
In output <strong>Stata</strong> unfortunately displays either the codes or the value labels, and you often need<br />
<strong>to</strong> see them both, <strong>to</strong> avoid mistakes. You may solve this by including the codes in the labels;<br />
this happens au<strong>to</strong>matically with:<br />
numlabel _all , add<br />
18