Announcement

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

  • retain string starting with certain value

    Hello!

    I have some stock codes (the variable is called ticker) which start with different numbers and all with 6 digits. I only want to retain those who start with 0, 3, or 6 and drop others (such as the bold ones in the example below). How can I do this? Thanks!

    Code:
    "600239"
    "001979"
    "300059"
    "300498"
    "200725"
    "000958"
    "600390"
    "900923"
    "600096"
    "000301"
    "900928"

  • #2
    Code:
    keep if inlist(substr(ticker, 1, 1), "0", "3", "6")

    Comment


    • #3
      Thanks this works!

      Comment

      Working...
      X