Announcement

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

  • rename variables with foreach (getting rid of prefix)

    Dear all,

    I have a data set which contains many variables e.g. with a country prefix: "mexiko_variablename", I would like to rename this variable without the name of the country in front of it.

    the normal way would just be
    rename mexiko_variablename variablename

    However, I have plenty of those variables and I would like to do it with a loop. Can someone tell me how this loop would look like?

    Many thanks in advance

  • #2
    Stata questions should be posted to the General forum;

    No loops needed here.

    Code:
    rename mexiko_* *
    or, enhancing readability

    Code:
    rename (mexiko_*) (*)
    Best
    Daniel

    Comment

    Working...
    X