Announcement

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

  • Replace label name with variable name

    Hi All,
    I'd like to replace the current variable labels in a set of datasets with their corresponding variable name.
    I have 7 datasets containing lab results from 7 countries, and I need to correct misleading/non-intuitive labels quickly, and the variable names will suffice..
    The variables in question are named sequentially plate1-plateX (the X in "plateX" above is a different number in each dataset).

    Essentially the opposite of the solution in this forum thread.
    Can this be done as easily? Ideally if there were a command that would do this (that I may have missed in my searching), then I can loop it through all 7 datasets.

    Hopefully this issue is simple enough to not need to upload example data or code but I'm happy to do so if needed.


    Many thanks,
    Shay

  • #2
    Perhaps this will start you on your way; code to be run in each of your datasets.
    Code:
    foreach v of varlist plate* {
        label variable `v' "`v'"
    }

    Comment


    • #3
      Thank you this works perfectly. I was able to solve similarly by invoking old code:
      Code:
      for var plate*: label var X X

      Comment

      Working...
      X