Announcement

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

  • Remove "weird" mixed names

    Hello everyone! I'd like to quickly remove those weird company names: "number + customers" in my data. My original code is to find each one of them and type in a long list of codes. Any efficient codes to achieve the same goal? Thank you!

    Code:
     cnms
    38 Customers
    4 companies
    4 customers
    39 Customers
    43 CUSTOMERS
    3900 Customers
    392 Customers

  • #2
    Code:
    g cnms2 = substr(cnms,1,strpos(cnms, " ")-1)

    Comment


    • #3
      Code:
      word(cnms, 1)
      would also work. You might also want to make it numeric with real().

      Comment


      • #4
        Another approach:

        Code:
        g code = ustrregexs(0) if ustrregexm(cnms, "[0-9]+")
        Roman

        Comment


        • #5
          #3. Of course.

          Comment


          • #6
            Hi everyone, the issue was resolved! Thank you so much for contributing the brilliant ideas! Have a good weekend!

            Comment

            Working...
            X