Value labels may exist in data without being attached to any variable. Such superfluous variable label sets can easily go unnoticed--not least since there's no easy method for identifying them and, if desired, removing them.
Implementation ideas
For collecting:
Get the names of all labels via r(names) returned by label dir
Get the list of variables that have this label via ds, has(vallabel label_name)
Collect the names of labels that have an empty return from ds above
Return these labels in r(names) (or other convetional name)
Problem
Value labels may exist in data without being attached to any variable. Such superfluous variable label sets can easily go unnoticed--not least since there's no easy method for identifying them and, if desired, removing them.
Implementation ideas
For collecting:
r(names)
returned bylabel dir
ds, has(vallabel label_name)
ds
abover(names)
(or other convetional name)For removing:
r(names)
tolabel drop