Announcement

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

  • Change the lenght of a string

    Hi,

    I have a dataset where the variable id is stored as a str9, although this id has only 8 characters of lenght in some registers. I have something like this (below). The id "00831782" has a lenght of 9 although it has only 8 characters and also it has been stored as a str9. I can see that there is a blank at the end of this registers so it counts them with a lenght of 9 (the are like stucked to the left in the browser). How I can remove this blank space at the final of this registers to identify the real lenght?

    Im trying to merge this registers with another database but i cant because this registers have been stored as str9 and have only 8 characters while in the other database the are stored as str8.


    id / length

    000532048 / 9
    000371958 / 9
    001246584 / 9
    00831782 / 9
    01322658 / 9
    01323954 / 9




    I would really appreciate if you could help me.

    Last edited by Luciana Pando; 01 Nov 2019, 13:32.

  • #2
    See strtrim, or ustrtrim for Unicode strings.

    Code:
    . di ("("+strtrim("  abc  ")+")")
    (abc)
    
    . di ("("+strltrim("  abc  ")+")")
    (abc  )
    
    . di ("("+strrtrim("  abc  ")+")")
    (  abc)
    Last edited by Jean-Claude Arbaut; 01 Nov 2019, 13:53.

    Comment


    • #3
      Merci bcp pour votre aide! Maintenant il marche!!!

      Comment

      Working...
      X