<?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: Importing csv file results in bizarre results in character string. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983941#M379621</link>
    <description>&lt;P&gt;Agree with Tom. It seems the problem is coming from &lt;SPAN&gt;ENCODING="UTF-8" , make sure the encoding of CSV is also "UTF-8" . You could check it with Notepad++&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tinyMceEditorKsharp_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="屏幕截图 2025-09-09 175017.png" style="width: 643px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/113329i700FCF29844522A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="屏幕截图 2025-09-09 175017.png" alt="屏幕截图 2025-09-09 175017.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Feb 2026 05:45:18 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2026-02-24T05:45:18Z</dc:date>
    <item>
      <title>Importing csv file results in bizarre results in character string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983914#M379616</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I need your help understanding the why behind the following issue and suggestions on how to fix it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an XLSX file I download from a vendor site (no back-end access allowed), save it to a .csv, move it to our SAS Server, and use SAS EG to import the .csv file as a dataset using a DATA STEP with Infile, Length, Label, Format, Informat, and Input all specified for full control.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my INFILE statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;INFILE &amp;amp;newfile.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LRECL=32767&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TERMSTR=CRLF&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FIRSTOBS=2&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MISSOVER&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TRUNCOVER&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ENCODING="UTF-8"&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DLM='2C'X&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DSD ;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some of the larger text fields do not import all characters properly such as a colon (:) or an apostrophe (') and I get a weird character box (&amp;#26;) instead of the colon or apostrophe. Does not seem to be happening with letters or numbers.&amp;nbsp; The issue is not consistent - sometimes it imports fine, other times it does not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect it's the UTF-8 statement, but what else can I use?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Paula&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Feb 2026 22:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983914#M379616</guid>
      <dc:creator>SASGeek</dc:creator>
      <dc:date>2026-02-23T22:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv file results in bizarre results in character string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983929#M379617</link>
      <description>&lt;P&gt;Did you save it as a UTF-8 CSV to begin with?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2026-02-24 125113.jpg" style="width: 683px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/113328i2DD7C5506601FDCB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2026-02-24 125113.jpg" alt="Screenshot 2026-02-24 125113.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;DIV id="tinyMceEditorSASKiwi_2" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;Otherwise using the ENCODING option is unlikely to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Feb 2026 23:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983929#M379617</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2026-02-23T23:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv file results in bizarre results in character string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983933#M379618</link>
      <description>&lt;P&gt;Why not just move the XLSX file to the SAS server and read it using the XLSX engine?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either with PROC IMPORT using DBMS=XLSX or by using a LIBNAME statement with the XLSX engine.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Feb 2026 23:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983933#M379618</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-02-23T23:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv file results in bizarre results in character string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983934#M379619</link>
      <description>&lt;P&gt;What is the setting for the system option ENCODING for the SAS session where you ran the data step?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(getoption(encoding));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If it is not UTF-8 then you are going to have trouble reading an UTF-8 file that uses anything that is not available in the encoding that you are using.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note that the ENCODING option can only be set when the SAS session starts.&amp;nbsp;&lt;/STRONG&gt; So if you are using Enterprise Guide to submit your SAS code you will need to make sure to connect to a SAS session that is setup using UTF-8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many characters in UTF-8 that look like a single quote but are really a different character.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www2.cs.sfu.ca/~ggbaker/reference/characters/#single" target="_blank" rel="noopener"&gt;https://www2.cs.sfu.ca/~ggbaker/reference/characters/#single&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really cannot control what encoding you are running in then read in the file using ENCODING=ANY on the INFILE statement.&amp;nbsp; You will then need to make your own code to translate any bytes strings representing UTF-8 characters into the proper bytes for your encoding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Change left single quote to normal single quote ;
charvar = tranwrd(charvar,'E28098'x,"'");
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2026 00:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983934#M379619</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-02-24T00:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv file results in bizarre results in character string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983941#M379621</link>
      <description>&lt;P&gt;Agree with Tom. It seems the problem is coming from &lt;SPAN&gt;ENCODING="UTF-8" , make sure the encoding of CSV is also "UTF-8" . You could check it with Notepad++&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tinyMceEditorKsharp_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="屏幕截图 2025-09-09 175017.png" style="width: 643px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/113329i700FCF29844522A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="屏幕截图 2025-09-09 175017.png" alt="屏幕截图 2025-09-09 175017.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2026 05:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983941#M379621</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2026-02-24T05:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Importing csv file results in bizarre results in character string.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983964#M379629</link>
      <description>&lt;P&gt;That would not help if the SAS session is not using UTF-8 encoding.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2026 15:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-csv-file-results-in-bizarre-results-in-character/m-p/983964#M379629</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2026-02-24T15:01:02Z</dc:date>
    </item>
  </channel>
</rss>

