<?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: Issues with special characters created with utf-8 encoding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911226#M359321</link>
    <description>&lt;P&gt;Read the file using ENCODING=ANY and then manually translate the non-ASCII codes into either single byte characters or some other things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example you could code like this to transcode the plus/minus symbol into the three character string +/- instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'textfile' encoding='any';
  input line $char100.;
  line = tranwrd(line,'C2B1'x,'+/-');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Jan 2024 03:56:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-01-11T03:56:11Z</dc:date>
    <item>
      <title>Issues with special characters created with utf-8 encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911206#M359315</link>
      <description>&lt;P&gt;I'm importing a csv using the following code:&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data finaldata;
&amp;nbsp; infile inputfile encoding='utf-8' truncover;
&amp;nbsp; input &amp;nbsp;mainline $varylen30000. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However some of the characters like em dash, en dash etc are being converted to unusual characters such as below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92439i410CDEAF69DA0757/image-size/small?v=v2&amp;amp;px=200" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've had success gaining the hyphen of en dash using the code below&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;mainline=mainline(tranwrd,'96'x,'-')&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but this is very specific to one of the cases I found. Is there someone way I could tackle all these special characters?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 00:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911206#M359315</guid>
      <dc:creator>rdum96</dc:creator>
      <dc:date>2024-01-11T00:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with special characters created with utf-8 encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911209#M359316</link>
      <description>&lt;P&gt;If your SAS session is not also using UTF-8 encoding then it might not be possible to transcode every character in your UTF-8 text file into single byte encodings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also with single byte encodings what glyph is displayed for any particular byte will depend of the FONT you are using.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 01:18:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911209#M359316</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-11T01:18:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with special characters created with utf-8 encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911214#M359317</link>
      <description>&lt;P&gt;To test if this is a read/transcode or a write/display issue you could run below and see what gets printed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data finaldata;
  em_dash='E28094'x;
  infile inp encoding='utf-8' truncover;
  input  mainline $10. ;
run;
proc print data=finaldata(obs=1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In my environment things are working:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1704939505122.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92441iF916F32E775674BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1704939505122.png" alt="Patrick_0-1704939505122.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 02:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911214#M359317</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-01-11T02:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with special characters created with utf-8 encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911216#M359318</link>
      <description>Ah gotcha! I believe I can't modify the SAS session &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; I looked into the encoding and looks like it's 'latin1'. I was hoping the encoding option in the infile statement would help! I'll try to hard code everything for the time being!</description>
      <pubDate>Thu, 11 Jan 2024 03:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911216#M359318</guid>
      <dc:creator>rdum96</dc:creator>
      <dc:date>2024-01-11T03:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with special characters created with utf-8 encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911218#M359319</link>
      <description>&lt;P&gt;Thank you! I just checked and I get other special characters upon performing this &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Image 1-10-24 at 10.04 PM.jpeg" style="width: 456px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92442i1FB5FF7D9E8F2FFD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image 1-10-24 at 10.04 PM.jpeg" alt="Image 1-10-24 at 10.04 PM.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 03:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911218#M359319</guid>
      <dc:creator>rdum96</dc:creator>
      <dc:date>2024-01-11T03:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with special characters created with utf-8 encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911226#M359321</link>
      <description>&lt;P&gt;Read the file using ENCODING=ANY and then manually translate the non-ASCII codes into either single byte characters or some other things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example you could code like this to transcode the plus/minus symbol into the three character string +/- instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'textfile' encoding='any';
  input line $char100.;
  line = tranwrd(line,'C2B1'x,'+/-');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jan 2024 03:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911226#M359321</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-11T03:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with special characters created with utf-8 encoding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911235#M359324</link>
      <description>&lt;P&gt;For me in a single byte session with WLATIN1 the Hex value is 97.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename inp "c:\temp\test_emdash_u8.csv";
data finaldata;
	em_dash='97'x;
	encoding="%sysfunc(getoption(encoding,keyexpand))";
	infile inp encoding='utf-8' truncover;
	input  mainline $10. ;
	hex=put(mainline,$hex20.);
run;
proc print data=finaldata(obs=1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1704953248404.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/92449iC936985CAE8DA1CA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1704953248404.png" alt="Patrick_0-1704953248404.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 06:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issues-with-special-characters-created-with-utf-8-encoding/m-p/911235#M359324</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-01-11T06:07:26Z</dc:date>
    </item>
  </channel>
</rss>

