<?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: Encoding problem while importing the file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720469#M223192</link>
    <description>&lt;P&gt;Are you running the SAS nls (National Language Support/Local language) version?&lt;/P&gt;
&lt;P&gt;Can you run SAS by "SAS(Unicode support)" short cut?&lt;/P&gt;
&lt;P&gt;The Excel file you are trying to work with contains unicode strings, so you should need SAS that can handle unicode, i.e. SAS unicode support.&lt;/P&gt;</description>
    <pubDate>Fri, 19 Feb 2021 14:33:27 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2021-02-19T14:33:27Z</dc:date>
    <item>
      <title>Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719287#M222703</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I woud like to import the attached file, but I don't know how to choose the encoding option. When I try to convert this file to csv I have the same encoding problem. My code is :&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mon_f temp;

	data _null_;
		infile "XXXXX\data_act.xlsx" dsd truncover lrecl=32767 encoding=wlatin1;
		file mon_f lrecl=1000000;
		input ligne :$char32767.;

		if notdigit(scan(ligne,1,',')) and length(scan(ligne,1,','))&amp;gt;1 then
			put '|' @;
		else if length(scan(ligne,1,','))&amp;gt;1 then
			do;
				put;
			end;

		len=lengthn(ligne);
		put ligne $varying32767. len @;
	run;

	proc import datafile=mon_f dbms=csv out=donnee replace;
		getnames=no;
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 09:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719287#M222703</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-02-15T09:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719301#M222707</link>
      <description>&lt;P&gt;Files with the extension xlsx are binary files, so I think it is difficult to process them with the file statement.&lt;/P&gt;
&lt;P&gt;I tried the following code, and it worked somewhat.&lt;/P&gt;
&lt;P&gt;I checked it with SAS9.4(Unicode support).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mon_f temp encoding='utf-8';
libname x xlsx "XXXXX\data_act.xlsx";

data _null_;
  set x.TWEET_ACTIVITY_METRICS_AG2RLMP_;
  file mon_f lrecl=1000000;

  if notdigit(scan(Identifiant_du_Tweet__Permalien,1,',')) and length(scan(Identifiant_du_Tweet__Permalien,1,','))&amp;gt;1 then
    put '|' @;
    else if length(scan(Identifiant_du_Tweet__Permalien,1,','))&amp;gt;1 then
    do; 
      put;
	end;
    len=lengthn(Identifiant_du_Tweet__Permalien);
	put Identifiant_du_Tweet__Permalien $varying32767. len @;
run;

proc import datafile=mon_f dbms=csv out=donnee replace;
	getnames=no;
run;
libname x;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can handle the newline in the red frame correctly, you may be able to import the file using proc import.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-02-15_18h19_09.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54732i885DEDD0CCD1FD05/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-02-15_18h19_09.png" alt="2021-02-15_18h19_09.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SAS dataset display is garbled, but I think that's just a problem of not having a font in my SAS that can display emoji.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-02-15_18h25_12.png" style="width: 432px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54733iAE03EAD4043BCE29/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-02-15_18h25_12.png" alt="2021-02-15_18h25_12.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 09:29:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719301#M222707</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-02-15T09:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719302#M222708</link>
      <description>Thank you, Kawakami</description>
      <pubDate>Mon, 15 Feb 2021 09:32:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719302#M222708</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-02-15T09:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719507#M222782</link>
      <description>&lt;P&gt;If you get garbled characters, try using wlatin1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename mon_f temp encoding='wlatin1';&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 00:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719507#M222782</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-02-16T00:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719513#M222786</link>
      <description>&lt;P&gt;Please try this code.&lt;/P&gt;
&lt;P&gt;I can get Emoji.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mon_f 'temp.dat' encoding='wlatin1';
libname x xlsx "C:\Users\xyzab\Downloads\data_act.xlsx";

data _null_;
  set x.TWEET_ACTIVITY_METRICS_AG2RLMP_;
  file mon_f lrecl=1000000;

  if notdigit(scan(Identifiant_du_Tweet__Permalien,1,',')) and length(scan(Identifiant_du_Tweet__Permalien,1,','))&amp;gt;1 then
    put '|' @;
    else if length(scan(Identifiant_du_Tweet__Permalien,1,','))&amp;gt;1 then
    do; 
      put;
	end;
    len=lengthn(Identifiant_du_Tweet__Permalien);
	put Identifiant_du_Tweet__Permalien $varying32767. len @;
run;
filename mon_f;
filename mon_f 'temp.dat' encoding='utf-8' nobom;
proc import datafile=mon_f dbms=csv out=donnee replace;
	getnames=no;
run;
filename mon_f;
libname x;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-02-16_10h11_35.png" style="width: 315px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54779i4A1C9929C0DFE222/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-02-16_10h11_35.png" alt="2021-02-16_10h11_35.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 01:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719513#M222786</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-02-16T01:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719547#M222807</link>
      <description>Thank you very much Kawakami ! For importing the emoji, do you use firstly the wlatin1 and after the utf-8 ? &lt;BR /&gt;&lt;BR /&gt;I don't have the authorization for temp.dat, could I use  another .dat ?  NOTE: Variable Identifiant_du_Tweet__Permalien is uninitialized.&lt;BR /&gt;ERROR: Insufficient authorization to access C:\Applications\SAS\SASConfig\Lev1\SASApp\temp.dat.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;&lt;BR /&gt;Thank you very much !</description>
      <pubDate>Tue, 16 Feb 2021 08:15:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/719547#M222807</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-02-16T08:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720342#M223142</link>
      <description>&lt;P&gt;please try this code.&lt;/P&gt;
&lt;P&gt;I think the Excel file was created on a PC with wlatin1 character encoding.&lt;BR /&gt;So, the encoding of the first filename needs to be wlatin1.&lt;BR /&gt;The encoding of the next filename needs to be utf-8 so that emoji can be imported into SAS.&lt;/P&gt;
&lt;P&gt;You can use any file name you want, even temp.dat.&lt;BR /&gt;The following code will create the file in the work library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mon_f "%sysfunc(pathname(work))\temp.dat" encoding='wlatin1';
libname x xlsx "XXXXX\data_act.xlsx";

data _null_;
  set x.TWEET_ACTIVITY_METRICS_AG2RLMP_;
  file mon_f lrecl=1000000;

  if notdigit(scan(Identifiant_du_Tweet__Permalien,1,',')) and length(scan(Identifiant_du_Tweet__Permalien,1,','))&amp;gt;1 then
    put '|' @;
    else if length(scan(Identifiant_du_Tweet__Permalien,1,','))&amp;gt;1 then
    do; 
      put;
	end;
    len=lengthn(Identifiant_du_Tweet__Permalien);
	put Identifiant_du_Tweet__Permalien $varying32767. len @;
run;
filename mon_f;
filename mon_f "%sysfunc(pathname(work))\temp.dat" encoding='utf-8' nobom;
proc import datafile=mon_f dbms=csv out=donnee replace;
	getnames=no;
run;
filename mon_f;
libname x;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Feb 2021 22:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720342#M223142</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-02-18T22:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720433#M223180</link>
      <description>&lt;P&gt;Hello Kawakami,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much ! Unfortunately, I have this error :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarieT_0-1613734637935.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54931i594C094495C63A42/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarieT_0-1613734637935.png" alt="MarieT_0-1613734637935.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarieT_1-1613734666049.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54932iA32F7140D1C2136D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarieT_1-1613734666049.png" alt="MarieT_1-1613734666049.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I can't get the expected result &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 11:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720433#M223180</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2021-02-19T11:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720440#M223181</link>
      <description>&lt;P&gt;Maxim 3: Know Your Data.&lt;/P&gt;
&lt;P&gt;Your variable is numeric, so you can't use a character format with it.&lt;/P&gt;
&lt;P&gt;Please do&amp;nbsp;&lt;STRONG&gt;ALWAYS&lt;/STRONG&gt; post the&amp;nbsp;&lt;STRONG&gt;COMPLETE&lt;/STRONG&gt; log of your steps, and do&amp;nbsp;&lt;STRONG&gt;ALWAYS&lt;/STRONG&gt; &lt;STRONG&gt;COPY/PASTE&lt;/STRONG&gt; the text into a window opened with the&amp;nbsp;&lt;STRONG&gt;&amp;lt;/&amp;gt;&lt;/STRONG&gt; button. Do&amp;nbsp;&lt;STRONG&gt;NOT&lt;/STRONG&gt; post logs as pictures.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 12:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720440#M223181</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-19T12:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Encoding problem while importing the file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720469#M223192</link>
      <description>&lt;P&gt;Are you running the SAS nls (National Language Support/Local language) version?&lt;/P&gt;
&lt;P&gt;Can you run SAS by "SAS(Unicode support)" short cut?&lt;/P&gt;
&lt;P&gt;The Excel file you are trying to work with contains unicode strings, so you should need SAS that can handle unicode, i.e. SAS unicode support.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 14:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Encoding-problem-while-importing-the-file/m-p/720469#M223192</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-02-19T14:33:27Z</dc:date>
    </item>
  </channel>
</rss>

