Announcement

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

  • Eliminating leading blanks from a string

    Hi all,

    It seems there are leading blanks for a string variable state in 2 out of 5 rounds of data sets I'm working with. Due to these leading blanks after appending, apparently same value of the string appears twice upon tabulating the state variable.

    I tried
    Code:
    keep if state=="XY"
    with spaces in different positions and could confirm that the space is on left of "XY". I could also identify the rounds in which these spaces occur by
    Code:
    tab state round
    and noting down the sample size under each value.

    However when I try
    Code:
    replace state==trim(state)
    on the offending rounds, I get "0 real changes made".

    Could someone please help me out?

    Thanks,


  • #2
    In case you have characters other than the ASCII space character, try

    Code:
    replace state=ustrtrim(state)
    See

    Code:
    help ustrtrim()

    Comment

    Working...
    X