|
Size: 911
Comment:
|
Size: 925
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| = Metadata = | = Stata Metadata = |
| Line 3: | Line 3: |
| Data about data. | Stata offers human-readable variable names, variable labels, variable printing formats, and value labels. Stata stores variable labels and value labels in a separate database. Many built-in commands seamlessly pull in metadata from that database, but there are notable exceptions. <<TableOfContents>> |
| Line 8: | Line 12: |
| == Labeling == | |
| Line 10: | Line 13: |
| === Variable Labels === | == Labels == Variable and value labels are defined using the '''`label`''' command. |
| Line 13: | Line 18: |
| label variable VAR "var" | label variable foo "yes or no?" label define yesno 1 "Yes" 0 "No" label values foo yesno |
| Line 16: | Line 23: |
| See [[Stata/Label|here]] for more options. | |
| Line 17: | Line 25: |
=== Value Labels === Value labels are defined separately from the actual dataset. |
Numeric values can be quickly prepended to value labels using the '''`numlabel`''' command. |
| Line 23: | Line 28: |
| label define LABEL 0 "No" 1 "Yes" label define LABEL 99 "Missing", modify label values VAR LABEL }}} By default, labels cannot be overwritten. The '''add''' option allows new values to be inserted into an existing label. The '''replace''' option allows existing values to be overwritten in an existing label. The '''modify''' option combines both. Numeric values can be added to value labels using the '''numlabel''' command. {{{ numlabel LABEL, add mask("#. ") |
numlabel foo, add mask("#. ") |
Stata Metadata
Stata offers human-readable variable names, variable labels, variable printing formats, and value labels.
Stata stores variable labels and value labels in a separate database. Many built-in commands seamlessly pull in metadata from that database, but there are notable exceptions.
Contents
Labels
Variable and value labels are defined using the label command.
label variable foo "yes or no?" label define yesno 1 "Yes" 0 "No" label values foo yesno
See here for more options.
Numeric values can be quickly prepended to value labels using the numlabel command.
numlabel foo, add mask("#. ")
Quick Tips
Stata has a number of interactive tools for examining metadata.
di _N // number of cases di c(k) // number of variables
