Announcement

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

  • I need a little help in data management

    Dear users:
    I need a little help. I have around 17000 names of firms. These are arranged like (1) A B G Motors Limited,(2) A B B Instrumentation Limited [Merged]. In my sample, we have companies that are unmerged & unmerged. The name ends with [Merged] at the end of merged companies. How to identify such companies in a sample of 17000 companies.

    Thank you!
    With kind regards,
    Amit

  • #2
    If by "identify" you mean "create a separate binary variable to identify merged companies," you could do this:
    Code:
    gen merged = strpos(lower(YourCompanyNameVariable), "[merged") > 0
    Various refinements to this (removing spaces etc.) are possible depending on whether your data is "clean," but without further information, this would be a reasonable first try.

    Comment


    • #3
      On the off-chance that "[Merged]" might appear elsewhere in the string and should then not count, you can use a simple regular expression match instead:

      Code:
      clear
      input str30 name
      "[my] [Merged] [Company]"
      "Othercompany [Merged]"
      end
      
      gen wanted = ustrregexm(name,"\[Merged\]$")
      li, noobs
      
        +----------------------------------+
        |                    name   wanted |
        |----------------------------------|
        | [my] [Merged] [Company]        0 |
        |   Othercompany [Merged]        1 |
        +----------------------------------+

      Comment


      • #4
        If a string ends in [Merged] then it's true that (assuming variable name name)


        Code:
        substr(name, -8, 8) == "{Merged]"
        but all sorts of things could undermine the success of testing for that condition, including extra spaces, different use of upper and lower case, and other punctuation.

        Comment


        • #5
          Thank you, professors!

          Comment

          Working...
          X