Announcement

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

  • Add same extension to existing variable labels

    I'm not sure how to phrase this question but I want to use all the existing variable labels but add the same additional information at the end of all the variable labels from the same dataset. For example it would be something like

    variable1 "Variable 1"
    variable2 "Variable 2"

    to

    variable1 "Variable 1 residential"
    variable2 "Variable 2 residential"

    The farthest I have gotten is using a foreach loop to use the variable name and add the same label extension to all the variables but not the original variable labels

    This is a sample of code for how far I've gotten

    clear
    sysuse auto.dta

    foreach x of varlist _all {

    local label: variable label `x'
    label var `x' "`x' Residential"

    }

    Any help for how to get the original variable labels with the "Residential" added would be appreciated.

  • #2
    nvm I figured it out. This is the code if anyone sees this

    foreach x of varlist _all {

    local y: variable label `x'
    label var `x' "`y' Residential"

    }

    Comment


    • #3
      elabel (SSC) is convenient here:

      Code:
      elabel variable (_all) (= @ + " Residential")

      Comment


      • #4
        Chiming in to say thank you, Elijah!

        Comment

        Working...
        X