<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I read in an Emoji in a CSV? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625260#M184280</link>
    <description>&lt;P&gt;Hi Bart,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your quick reply.&amp;nbsp; I tried your code below and I still got the error message.&amp;nbsp; I am working in a WLATIN1 environment.&amp;nbsp; SAS is installed on a server and so I don't want to change the default encoding since this will affect all other users.&amp;nbsp; Is there are way to handle this programmatically?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
    <pubDate>Mon, 17 Feb 2020 13:46:37 GMT</pubDate>
    <dc:creator>AndrewJones</dc:creator>
    <dc:date>2020-02-17T13:46:37Z</dc:date>
    <item>
      <title>How do I read in an Emoji in a CSV?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625252#M184277</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to import into SAS a CSV file which contains SMS messages.&amp;nbsp; The SMS message can include emojis.&amp;nbsp; Whenever I use either PROC IMPORT or an INFILE statement to read in an emoji, the program fails with the message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Invalid string.&lt;BR /&gt;FATAL: Unrecoverable I/O error detected in the execution of the DATA step program. Aborted during the EXECUTION phase.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The rest of the file is not imported into SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of a CSV file with an emoji is: (taken from the attached file)&lt;/P&gt;&lt;P&gt;"Delivery Status","Question Label","Question DateTime","Answer Label","Answer DateTime","Answer Text"&lt;/P&gt;&lt;P&gt;"Delivered","3","02/07/2019 08:22:39","Invalid Response","04/07/2019 10:31:43","&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to either get SAS to ignore the emoji and carry on processing the CSV file, or better still, process the emoji and give a text version of this.&amp;nbsp; I have found examples where people have done this with emoticons, and so I wondered if anyone had updated this to handle emojis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using EG 7.15 with SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that this is clear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 13:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625252#M184277</guid>
      <dc:creator>AndrewJones</dc:creator>
      <dc:date>2020-02-17T13:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I read in an Emoji in a CSV?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625253#M184278</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105391"&gt;@AndrewJones&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did this on your example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename f "C:\Users\&amp;amp;sysuserid.\Downloads\Sample.csv" encoding='utf-8';

data test;
  infile f firstobs=2 DSD;
  input (DeliveryStatus QuestionLabel QuestionDateTime AnswerLabel AnswerDateTime AnswerText) (: $ 20.);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and it worked. Are you working in UTF-8 session?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 13:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625253#M184278</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-02-17T13:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I read in an Emoji in a CSV?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625260#M184280</link>
      <description>&lt;P&gt;Hi Bart,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your quick reply.&amp;nbsp; I tried your code below and I still got the error message.&amp;nbsp; I am working in a WLATIN1 environment.&amp;nbsp; SAS is installed on a server and so I don't want to change the default encoding since this will affect all other users.&amp;nbsp; Is there are way to handle this programmatically?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 13:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625260#M184280</guid>
      <dc:creator>AndrewJones</dc:creator>
      <dc:date>2020-02-17T13:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I read in an Emoji in a CSV?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625289#M184291</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/105391"&gt;@AndrewJones&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tray the code below, it looks like you have UTF file with bit order mask (BOM). I've tested it on my Wlatin1 sas session.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Someone smarter than we (&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&amp;nbsp;) already answered this in the following thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Import-issue-Invalid-string-Unrecoverable-I-O-error/td-p/517562" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Import-issue-Invalid-string-Unrecoverable-I-O-error/td-p/517562&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;=sysencoding.;

filename f "C:\Users\&amp;amp;sysuserid.\Downloads\Sample.csv";

data _null_;
  infile f recfm=N;
  input c $char10.;
  put c $hex20.;
  stop;
run;

filename T "%sysfunc(pathname(work))/temp" recfm=N;
data _null_;
  infile f recfm=N;
  file t recfm=N;
  if _n_=1 then input +3 @@; /* skip first three bytes (adapt if BOM is longer) */
  input c $char1.;
  put c $1.;
run;
filename T "%sysfunc(pathname(work))/temp" recfm=V;

data test;
  infile t firstobs=2 DSD ; /*dlm='0a0d'x;*/
  input (DeliveryStatus QuestionLabel QuestionDateTime AnswerLabel AnswerDateTime AnswerText) (: $ 20.);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 14:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625289#M184291</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-02-17T14:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I read in an Emoji in a CSV?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625299#M184295</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perfect.&amp;nbsp; This works like a charm.&amp;nbsp; Thanks for finding the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 15:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-read-in-an-Emoji-in-a-CSV/m-p/625299#M184295</guid>
      <dc:creator>AndrewJones</dc:creator>
      <dc:date>2020-02-17T15:12:07Z</dc:date>
    </item>
  </channel>
</rss>

