|
Size: 649
Comment:
|
← Revision 16 as of 2025-10-24 15:58:53 ⇥
Size: 942
Comment: Rewrite
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 13: | Line 13: |
| Variable and value labels are defined using the '''`label`''' command. | Variable and value labels are primarily manipulated by the [[Stata/Label|`-label-`]] command. |
| Line 16: | Line 16: |
| label variable foo "yes or no?" label define yesno 1 "Yes" 0 "No" label values foo yesno |
. label variable foo "yes or no?" . label define yesno 1 "Yes" 0 "No" . label values foo yesno . label list yesno yesno: 0 No 1 Yes |
| Line 21: | Line 28: |
| See [[Stata/Label|here]] for more options. Numeric values can be quickly prepended to value labels using the '''`numlabel`''' command. |
Numeric values can be quickly prepended to value labels using the '''`-numlabel-`''' command. |
| Line 27: | Line 32: |
| }}} To access or store the text of a variable label, try: {{{ local varlab_foo: variable label foo }}} To manipulate value labels, try: {{{ local vallab_foo: value label foo local vallab_foo_1: label `vallab_foo' 1, strict |
Stata Metadata
Stata exposes a rich API for querying internal metadata.
Contents
Labels
Variable and value labels are primarily manipulated by the `-label-` command.
. label variable foo "yes or no?"
. label define yesno 1 "Yes" 0 "No"
. label values foo yesno
. label list yesno
yesno:
0 No
1 YesNumeric values can be quickly prepended to value labels using the -numlabel- command.
numlabel foo, add mask("#. ")To access or store the text of a variable label, try:
local varlab_foo: variable label foo
To manipulate value labels, try:
local vallab_foo: value label foo local vallab_foo_1: label `vallab_foo' 1, strict
Descriptives
display _N // number of cases display c(k) // number of variables
