Announcement

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

  • Insert hyphen in string

    Hi friends:

    I have a string variable where some of the values are a number, followed by a space, and then the letters "orig". such as "54 orig"
    I would like to insert a hyphen in the place of the space, for all such string variable values.
    Example: "54-orig"
    What would be the command?

    Thanks!

  • #2
    If you're sure of what changes and what doesn't, then you could try something like
    Code:
    generate str new_var = subinstr(var, " orig", "-orig", 1)

    Comment


    • #3
      Originally posted by Joseph Coveney View Post
      If you're sure of what changes and what doesn't, then you could try something like
      Code:
      generate str new_var = subinstr(var, " orig", "-orig", 1)
      Thanks a lot Joseph! It works well!

      Comment

      Working...
      X