<?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: Reading json files with unicode characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930424#M366068</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/54209"&gt;@HeidiDT&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you - this worked perfectly!! Now I will discuss changing the encoding permanently with our SAS Admins.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No.&amp;nbsp; Don't change it.&amp;nbsp; Instead make both available.&amp;nbsp; So the USER can decide which encoding they want to use for this particular SAS session.&lt;/P&gt;</description>
    <pubDate>Fri, 31 May 2024 13:12:09 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-05-31T13:12:09Z</dc:date>
    <item>
      <title>Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930112#M365945</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;
&lt;P&gt;I have searched and searched the web for answers, but am just not winning. I am reading a json file with unicode characters that are causing the error "Some code points did not transcode.". Some of the specific values are:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;- \"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;- \u&lt;EM&gt;digits&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I have tried this:&amp;nbsp;filename test &lt;EM&gt;'/filepath/filename&lt;/EM&gt;.json' encoding='UTF-8';&lt;BR /&gt;libname data JSON fileref=test ordinalcount=ALL;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but I still get the same error. Any ideas please? Unfortunately I cannot attach the file as it contains sensitive data.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 12:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930112#M365945</guid>
      <dc:creator>HeidiDT</dc:creator>
      <dc:date>2024-05-29T12:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930115#M365948</link>
      <description>&lt;P&gt;Is your SAS session running with unicode support?&amp;nbsp; Check the value of the system option ENCODING.&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 you are using a single byte encoding like WLATIN1 then there are MANY unicode values that cannot be transcoded into one of the 256 possible single byte characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try reading the file in a SAS session that was started with ENCODING='UTF-8'&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 12:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930115#M365948</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-29T12:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930117#M365950</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Encoding = LATIN1. We are running SAS on servers, so I don't have the ability to change that. I can of course as our admin guys ro do it, but I will have to prove that there will be no impact to our existing processes - a major undertaking. Is that the only way to do this? So specifying encoding = 'UTF-8' in the filename statement is not sufficient?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 12:29:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930117#M365950</guid>
      <dc:creator>HeidiDT</dc:creator>
      <dc:date>2024-05-29T12:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930118#M365951</link>
      <description>&lt;P&gt;There is a separate place in hell for admins who do not set SAS server to utf-8 in XXI century. ;-D But jokes aside.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have command line access to the server, by PuTTy, MobaXterm or similar software?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do, you can rum sas session in command line with utf-8 encoding and then execute your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let us know if you can, and if you need any support. Process is pretty easy, but if you never done it some support may be needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 12:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930118#M365951</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-05-29T12:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930119#M365952</link>
      <description>&lt;P&gt;You don't have to change your existing processes. Just run this job that needs it with Unicode support.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your SAS admins should be providing you with ways to run SAS with Unicode support.&amp;nbsp; If you are running SAS on your PC it should be part of the normal install.&amp;nbsp; You should see SAS 9.4 (English) and SAS 9.4 (Unicode Support) as available commands/apps to run in Windows.&amp;nbsp; If you are running from the command line you would normally either have two different commands (sas94 and sas94_unicode for example).&amp;nbsp; Or two different SAS configuration files you could point at.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using SAS/studio or Enterprise Guide you should have a choice of an App server that supports Unicode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem with trying to read Unicode characters when running a single byte encoding is like trying to put 10 pounds of potatoes into a five pound bag.&amp;nbsp; They is no place to put the extra characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can read the JSON file as just a text file.&amp;nbsp; You could then parse it yourself.&amp;nbsp; Or translate the unicode yourself into some sequence of ANSI characters instead.&amp;nbsp; But that might take more effort than having your SAS admins just do their jobs.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 12:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930119#M365952</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-29T12:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930258#M365989</link>
      <description>&lt;P&gt;Hi Bart&lt;/P&gt;
&lt;P&gt;Thanks for this! I do have access tot he server via Putty, but will need help in order to run a SAS session via the command line please - I have never done that.&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 11:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930258#M365989</guid>
      <dc:creator>HeidiDT</dc:creator>
      <dc:date>2024-05-30T11:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930318#M366017</link>
      <description>&lt;P&gt;ok, so the first step is to locate your sas home directory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run the following in your SAS Session to see the directory location:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename f "!SASHOME";
filename f list;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you should see something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/path/to/sashome&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in your log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next step:&lt;/P&gt;
&lt;P&gt;Save the code you want to run in a file in your home directory, let say file will be "mycode.sas".&lt;/P&gt;
&lt;P&gt;You can do it from your sas session by running something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
file '~/mycode.sas';
infile CARDS4;
input;
put _infile_;
CARDS4;
/* your code starts here */

libname x "/some/path/to/some/data";

data mydata;
  set x.someDataSet;

run;

/* your code ends here */
;;;;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you are ready, open Putty.&lt;/P&gt;
&lt;P&gt;Navigate to your home directory by typing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cd ~/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and hit Enter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Type:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ls -l&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to see if the&amp;nbsp;"mycode.sas" is there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then run the following line from command line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/path/to/sashome/SASFoundation/9.4/sas -encoding utf-8 ./mycode.sas&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the log from the execution will be created automatically in your home directory as "mycode.log"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can add:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;=sysencoding.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;at the beginning of your code to see if the command line session started in UTF-8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 18:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930318#M366017</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-05-30T18:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930422#M366066</link>
      <description>&lt;P&gt;Thank you - this worked perfectly!! Now I will discuss changing the encoding permanently with our SAS Admins.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 12:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930422#M366066</guid>
      <dc:creator>HeidiDT</dc:creator>
      <dc:date>2024-05-31T12:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading json files with unicode characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930424#M366068</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/54209"&gt;@HeidiDT&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you - this worked perfectly!! Now I will discuss changing the encoding permanently with our SAS Admins.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No.&amp;nbsp; Don't change it.&amp;nbsp; Instead make both available.&amp;nbsp; So the USER can decide which encoding they want to use for this particular SAS session.&lt;/P&gt;</description>
      <pubDate>Fri, 31 May 2024 13:12:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-json-files-with-unicode-characters/m-p/930424#M366068</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-05-31T13:12:09Z</dc:date>
    </item>
  </channel>
</rss>

