<?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 to fix the encoding problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-the-encoding-problem/m-p/797024#M255810</link>
    <description>&lt;P&gt;So either the creator of the dataset provided invalid UTF-8 bytes in the file.&lt;/P&gt;
&lt;P&gt;Or the other issue mentioned in the error message is happening. Is the file corrupted?&lt;/P&gt;</description>
    <pubDate>Thu, 17 Feb 2022 19:29:06 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-02-17T19:29:06Z</dc:date>
    <item>
      <title>How to fix the encoding problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-the-encoding-problem/m-p/797019#M255809</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I use SAS Studio and have the problem with encoding of sas dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data dt;
set inlib.dt;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get the error and 0 row in work.dt dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;ERROR: Some character data was lost during transcoding in the dataset WORK.DT. Either the data contains characters that are not representable in the new encoding or truncation occurred during transcoding.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;So, I run the next code. And we can see that encodings are equal.&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let dsn=inlib.dt;
%let dsid=%sysfunc(open(&amp;amp;dsn,i));
%let encoding=%sysfunc(attrc(&amp;amp;dsid,encoding)).;
%let rc=%sysfunc(close(&amp;amp;dsid));
%put The encoding for data set &amp;amp;dsn is: &amp;amp;encoding.;
%put The SAS session encoding is: &amp;amp;sysencoding.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;==&amp;gt; Log:&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE class=""&gt;    %let dsn=inlib.dt;
    %let dsid=%sysfunc(open(&amp;amp;dsn,i));
    NOTE: Data file INLIB.DT.DATA is in a format that is native to another host, or the file encoding does not match the session encoding. Cross Environment Data Access will be used, which might require additional CPU resources and might reduce performance.
    WARNING: Some character data was lost during transcoding in the dataset INLIB.DT. Either the data contains characters that are not representable in the new encoding or truncation occurred during transcoding.
    %let encoding=%sysfunc(attrc(&amp;amp;dsid,encoding)).;
    %let rc=%sysfunc(close(&amp;amp;dsid));
    %put The encoding for data set &amp;amp;dsn is: &amp;amp;encoding.;
    &lt;STRONG&gt;The encoding for data set inlib.dt is: utf-8 Unicode (UTF-8).&lt;/STRONG&gt;
    %put The SAS session encoding is: &amp;amp;sysencoding.;
    &lt;STRONG&gt;The SAS session encoding is: utf-8&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;SAS session encoding and data set encoding are the same.&lt;/DIV&gt;&lt;DIV class=""&gt;What's wrong? What to do?&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;inlib.dt contains the &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Cyrillic symbols. I can open this dataset in SAS Studio and all symbols display ok.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Thank you!&lt;/DIV&gt;</description>
      <pubDate>Thu, 17 Feb 2022 19:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-the-encoding-problem/m-p/797019#M255809</guid>
      <dc:creator>A_n_</dc:creator>
      <dc:date>2022-02-17T19:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix the encoding problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-the-encoding-problem/m-p/797024#M255810</link>
      <description>&lt;P&gt;So either the creator of the dataset provided invalid UTF-8 bytes in the file.&lt;/P&gt;
&lt;P&gt;Or the other issue mentioned in the error message is happening. Is the file corrupted?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 19:29:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-the-encoding-problem/m-p/797024#M255810</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-17T19:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix the encoding problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-the-encoding-problem/m-p/797051#M255822</link>
      <description>&lt;P&gt;I think you are right about invalid UTF-8 bytes in the file.&lt;BR /&gt;I try with other dataset. And it's okay.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The first dataset doesn't seem corrupted because I can open it in SAS Studio and can use "proc print".&lt;/P&gt;&lt;P&gt;So, I think the problem is decided &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Need the new correct dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 20:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-the-encoding-problem/m-p/797051#M255822</guid>
      <dc:creator>A_n_</dc:creator>
      <dc:date>2022-02-17T20:15:43Z</dc:date>
    </item>
  </channel>
</rss>

