Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extracting label names based on values

    Hello
    I have a program that labels some tables of STATA output with variable names based on a varlist

    I can extract the value label from var `v' using:

    Code:
    local labval : value label `v'
    and then get the label list using:

    Code:
    label list `labval'
    which gives me some output like this (for variable race as an example)

    Code:
    race_:
              -1 Unknown
               1 White
               2 Black
               3 Asian
               4 Pacific Islands
               5 Native American
               6 Other
    I want to be able to get the string of the label based on the number which corresponds to the label - eg some command that if I know that race = 2, I get "Black" out from the race_ value label. I cant seem to figure out how to do this. Any help would be appreciated.

    thanks for the help

    hpw


  • #2
    Code:
    local label : label (`v') 2
    Also, see elabel (SSC, SJ, GitHub).

    Comment


    • #3
      thanks! thats exactly what I needed

      Comment

      Working...
      X