Announcement

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

  • cutting the last two digits of a variable to create a new ID variable

    Hi all,

    I am working with a list of thousands of ID numbers that look like this:

    0001006 02
    0001011 03
    0001015 01
    0001019 03

    I need to cut the last two digits so that just the first seven remain. so the new variable would then be:

    0001006
    0001011
    0001015
    0001019

    Any idea how to do this? The variables are strings.
    Last edited by Steph Davis; 07 Nov 2018, 01:39. Reason: edited to include tags

  • #2
    I see spaces in your identifiers. That being so, either of these suggests technique for a generate command using your identifier variable name.

    Code:
    . di word("0001006 02", 1)
    0001006
    
    . di substr("0001006 02", 1, 7)
    0001006
    See for more information

    Code:
    help string functions

    Comment

    Working...
    X