Announcement

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

  • Extracting first two units of string

    Hello, I have a string variable that is an ID, and I just want to generate a new var with the first two numbers of that string. So if it was "078394", I would want a new var with just "07". I have been trying with -substr- and -regexs- and seem to just not be getting the syntax correct. Thank you.

  • #2
    Try
    Code:
    gen newvar = substr(ID,1,2)

    Comment


    • #3
      That worked! I was making it too complicated on myself. Thank you.

      Comment

      Working...
      X