Announcement

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

  • how to split?

    hello
    I want to split charcters into some parts. For example , I want to split "123456" to three parts: first part "12" , second "345" , third "6".
    would you help?

  • #2
    Well, what is the general pattern you want to follow? Are you always starting with 6 characters, and is it always the first two characters, followed by the next three, followed by the sixth? If so:

    Code:
    gen part1 = substr(my_string_var, 1, 2)
    gen part2 = substr(my_string_var, 3, 3)
    gen part3 = substr(my_string_var, 6, 1)
    If that's not the general rule you want to follow, you need to make it clear what the possibilities actually are.

    Comment


    • #3
      Thanks , It's very usefull.

      Comment

      Working...
      X