Announcement

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

  • My Stata do-file doesn't make any difference between ’ and '

    Hello. I had trouble linking frames together because some of my values were written with a right (not straight) single quotation mark ’ when others, all other characters remaining constant, were written with an apostrophe '. I am trying to fix the problem by using the subinstr() function however I don't know why my do-file editor cannot make the difference between the two symbols i.e. it types them both as an apostrophe even when I'm pasting the right quotation mark.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str15 label str732 varname
    "C5" "site d’accueil"
    "C5" "site d'accueil"  
    end
    Does this have to do with the fact that I'm using a French keyboard ?

    When I enter this data example in my Stata software it goes back to normal, so I'm not sure you will be able to replicate the data. My goal is to remove every possible right single quotation mark (not the one used for macros !). Thank you for your help !
    Last edited by Thomas Brot; 05 Mar 2023, 12:16.

  • #2
    You are right, that the -dataex- does not reproduce the problem. Even though in the do-file editor it shows a right quote (not apostrophe), when you run the -dataex- output the variable comes up with an apostrophe in that place. But by copy/pasting "site d’accueil" into the data editor, I was able to get the right quote into the data in memory. From there, I was able to verify that
    Code:
    replace varname = usubinstr(var1, "`=uchar(8217)'", "'", .)
    will do what you ask.

    Comment


    • #3
      Clyde : Thank you very much for your help. As always, your code worked like a charm.

      Comment

      Working...
      X