|
Size: 911
Comment:
|
Size: 1539
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 === | == Variable Labels == Variable labels are defined using the '''`label`''' command. |
| Line 13: | Line 18: |
| label variable VAR "var" | label variable foo "bar" |
| Line 15: | Line 20: |
Variable metadata including labels can be inspected and exported using the '''`describe`''' command. {{{ preserve describe, replace assert varlab=="bar" if name=="foo" restore }}} ---- |
|
| Line 18: | Line 34: |
| === Value Labels === | == Value Labels == |
| Line 20: | Line 36: |
| Value labels are defined separately from the actual dataset. | Variable labels are defined using the '''`label`''' command. However, they must first be defined as a label and then linked to one or more variables. |
| Line 23: | Line 39: |
| label define LABEL 0 "No" 1 "Yes" label define LABEL 99 "Missing", modify label values VAR LABEL |
label define baz 0 "No" 1 "Yes" label define baz 99 "Missing", modify label values foo baz |
| Line 28: | Line 44: |
| 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. | 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. |
| Line 30: | Line 46: |
| Numeric values can be added to value labels using the '''numlabel''' command. | Numeric values can be added to value labels using the '''`numlabel`''' command. |
| Line 33: | Line 49: |
| numlabel LABEL, add mask("#. ") | numlabel baz, 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.
Variable Labels
Variable labels are defined using the label command.
label variable foo "bar"
Variable metadata including labels can be inspected and exported using the describe command.
preserve describe, replace assert varlab=="bar" if name=="foo" restore
Value Labels
Variable labels are defined using the label command. However, they must first be defined as a label and then linked to one or more variables.
label define baz 0 "No" 1 "Yes" label define baz 99 "Missing", modify label values foo baz
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 baz, 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
