Announcement

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

  • String Manipulation

    Hi all!

    I have a dataset which has a bunch of wayward spaces randomly and non-uniformly strewn at the beginning and end of string entries. Is there a quick way to eliminate these?
    What I have right now is akin to
    CURRENT:
    Name:
    " Tom "
    "Billy "
    " Gus"
    "Lucky Joe "
    "Johnny the Navigator"

    The string variable I'd LIKE to have is
    DESIRED:
    Name:
    "Tom"
    "Billy"
    "Gus"
    "Lucky Joe"
    "Johnny the Navigator"


    I assume this one is not too much of a behemoth if you know what you're doing; I'm still relatively new to Stata and string manipulation is a skill I haven't built up in great degree so far. Thanks all for your time!

  • #2
    Quick clarification -- so if there's a way to remove only a specific character (space) from the beginning and end of every string in this variable, that's exactly what I'm looking for. Thanks again!

    Comment


    • #3
      Code:
      help strtrim()

      Comment


      • #4
        Exactly what I wanted Andrew; thanks so much

        Comment

        Working...
        X