Announcement

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

  • Return Variable label

    Is there a function that will return the variable label.

    I just want to be clear that I am talking about the "variable label" and not the "value label"

    Ultimately I want to use putexcel to put the variable label in a cell of an excel file.

    Thanks
    Owner of StataTutor.com

  • #2
    See help extended_fcn; to retrieve the label of variable -myvar-

    Code:
    local varlabel : var label myvar
    hth,
    Jeph

    Comment


    • #3
      Thanks for the help. That is definitely the functionality I was looking for.

      I am getting an error

      my code is:
      Code:
      foreach var in `varlist'{
          local varlabel : variable label `var'
          putexcel  A1=(`var') B1=(`varlabel') using "test `c(current_date)'", modify sheet("`var'")
          }
      The error I get is "Age not found" where "Age" is the first word of the variable label of the first variable. I have tried modifying the local `varlist' and whatever is the first variable, the first word in it's variable label will be the word in the error.
      Owner of StataTutor.com

      Comment


      • #4
        Try "`varlabel'"

        Comment


        • #5
          Thanks, This worked.
          Owner of StataTutor.com

          Comment

          Working...
          X