Announcement

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

  • Combining words

    Hi Everyone,

    I have a simple question that the answer could be to do it on excel, but I am wondering if this is possible to be done on STATA.

    my variable is "installer_name" that has a list of the solar installer in California. One installer, for example, is called "Sun power", however, I need all the names that consist of two-words to be combined on one single word like this "Sunpower".

    Does anyone know how this could be done on stata?

    Best
    Ali

  • #2
    The key term you needed to know is "string functions." See -help string functions-. Stata has a very large number of string functions, well beyond what you would find in Excel. However, for your problem, what you need is simple, namely the subinstr() function, which substitutes new content in strings for existing content. Presuming that all instances of two words in installer_name are separated by a space, you want to substitute nothing ("") for all instances of a space (" ")

    Code:
    replace installer_name = subinstr(installer_name, " ", "", .)
    If there are names with more than two words, though, this will also take away the spaces and make them all one word.

    Comment


    • #3
      Thank you so much for this help!

      Appreciated...

      Comment

      Working...
      X