Announcement

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

  • Printing the label names of variables

    I have a large dataset with variables and their labels. I am trying to print the label names of each variable, just to have a variable name and its label, but I am not able to find a code for that. Can someone please help with that? Thank you in advance!

  • #2
    When you refer to "labels" it is unclear whether you are referring to variable labels or value labels. A variable might have either one, both, or neither. On the assumption that you want both:

    Code:
    foreach v of varlist _all {
        display `"`v'"', `"`:var label `v''"', `"`:val label `v''"'
    }

    Comment


    • #3
      Does print mean display? See the results of

      Code:
      describe

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        When you refer to "labels" it is unclear whether you are referring to variable labels or value labels. A variable might have either one, both, or neither. On the assumption that you want both:

        Code:
        foreach v of varlist _all {
        display `"`v'"', `"`:var label `v''"', `"`:val label `v''"'
        }
        Thank you very much for your help. I actually wanted variable labels and your code worked well. Thank you!

        Comment

        Working...
        X