Announcement

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

  • Help with strtrim 2

    Hello,

    I am new to Stata and I am having the same problem as Alyssa Beavers mentioned in her post "Help with strtrim", except the suggested solution does not work in my case. I use Likert variables (imported from Excel) and some values have trailing spaces ("très bien " and "assez bien ") for the example below (the variable type is str27):

    list SentBien in 1/10

    +-----------------+
    | SentBien |
    |-----------------|
    1. | très bien |
    2. | légèrement bien |
    3. | très bien |
    4. | assez bien |
    5. | assez bien |
    |-----------------|
    6. | assez bien |
    7. | légèrement bien |
    8. | neutre |
    9. | assez mal |
    10. | neutre |
    +-----------------

    I executed the command "replace SentBien = strtrim(SentBien)" without error but I received the message "(0 real changes made)".
    It seems that the blank space in the value is not the regular blank space from my keyboard because if I type the command ---- count if SentBien=="très bien " --- it returns 0 but if I copy paste the "très bien " from the screen, then the command returns 108. However, in both cases, there is (what seems to be) one blank space at the end of the string.

    Do you have an explanation of this? And a solution to still delete those trailing spaces?

    Thank you in advance for your help!

  • #2
    See this thread https://www.statalist.org/forums/for...-a-space/page2

    In general, use chartab (SSC) to find out what characters you do have.

    In particular, a guess is that uchar(160) is the nuisance character to be removed.

    Comment


    • #3
      edit: I had the same problem in Excel (i.e. space not recognized as space) and I found a solution via Excel... I copypasted the "weird" space and remplaced it with the "normal" space (through Ctrl+H)... now "strtrim" works in Stata

      Comment

      Working...
      X