Announcement

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

  • Erase part of string before/after a character

    Hi all, if I have a variable with values that all follow the same pattern: "29.34.52.92", where the variable is a string and has different sequences of four two-digit numbers separated by periods...

    (1) How can I remove the second half of the string, such that my example would be left as"29.34", and
    (2) How can I remove the first half of the string, such that my example would be left as "52.92"?

  • #2
    if they are all the same, then substr would work.

    g first = substr(varname,1,5)
    g second = substr(varname,7,.)

    Comment


    • #3
      See continued discussion
      Last edited by daniel klein; 01 Aug 2023, 03:24.

      Comment

      Working...
      X