Announcement

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

  • Remove last letters of a string variable.

    Hello everyone.
    I have a variable that contains the name of countries, however, at the end of the string appears the year. Example, the variable is called country and the observations follow this structure "Colombia2020", I want to remove the year that appears at the end to have a variable that is the name of the country.


    Thanks for any help you can give me

  • #2
    replace var = ustrregexra(var, "([0-9])", "")

    Comment


    • #3
      Thank you George Ford for your help.
      The code was executed correctly.

      Comment


      • #4
        Also

        Code:
        replace var = substr(var, 1, strlen(var) - 4))

        Comment


        • #5
          Thank you Nick Cox for your help.

          Comment

          Working...
          X