<?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: Problem macro import_csv with filename encoding uft-8 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429731#M106158</link>
    <description>&lt;DIV class="tw-swapa"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="_Ejb"&gt;&lt;DIV&gt;&lt;DIV class="tw-ta-container tw-nfl"&gt;&lt;PRE class="tw-data-text tw-ta tw-text-small"&gt;&lt;SPAN&gt;I agree with you, but the marcro checks the file and also checks if it is possible to import the file. That is why the outf contains the path of the CSV as well as the encoding.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 22 Jan 2018 18:31:42 GMT</pubDate>
    <dc:creator>lavm01</dc:creator>
    <dc:date>2018-01-22T18:31:42Z</dc:date>
    <item>
      <title>Problem macro import_csv with filename encoding uft-8</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429709#M106145</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Libname Libsas 'E:\libsas\Itop';
Filename FichCsv2 'O:\Sc-Performance\PFI\ITOP\input_data\SCCM\Itop_Extraction_SCCM2012_lab.csv' ENCODING="utf-8";

%macro import_csv(outf,outds);
 %put outf=&amp;amp;outf;
 %let filrf=myfile;
 %put filrf=&amp;amp;filrf;
 %if %sysfunc(fileexist(&amp;amp;outf)) %then %do;
 %let rc=%sysfunc(filename(filrf,&amp;amp;outf));
 %let fid=%sysfunc(fopen(&amp;amp;filrf));
  %if &amp;amp;fid &amp;gt; 0 %then %do;
   %let rc=%sysfunc(fread(&amp;amp;fid));
   %let rc=%sysfunc(fget(&amp;amp;fid,mystring));
   %let rc_close=%sysfunc(fclose(&amp;amp;fid));
    %if &amp;amp;rc = 0 %then %do;
       proc import file="&amp;amp;outf." out=&amp;amp;outds
                   DBMS=DLM REPLACE;
				   Delimiter=';';
                   Guessingrows=32767;
                   Getnames=Yes;
       run;
    %end;
    %else %do;
      %put Fichier &amp;amp;outf. importation impossible fichier vide.;
	  Data _NULL_;
	   Date = today();
	   Format Date yymmdd10.;
	   File Sortie Notitles Mod;
	   put @50 "En date du: " Date +(-1)"," /;
	   put @10 "Le fichier &amp;amp;outf est vide.";
	  run;
	%end;
  %end;
 %let rc=%sysfunc(filename(filrf));
 %end;
 %else %put fichier existe pas;
%mend import_csv;



%import_csv(O:\Sc-Performance\PFI\ITOP\input_data\SCCM\Itop_Extraction_SCCM2012_lab.csv,Libsas.ItopSCCMLAB);
*%import_csv("&amp;amp;Fich2.",Libsas.ItopSCCMLAB);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;Can not pass the filename with encoding. is there a way to pass him the filename or some other way because I have to keep the encoding.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429709#M106145</guid>
      <dc:creator>lavm01</dc:creator>
      <dc:date>2018-01-22T17:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem macro import_csv with filename encoding uft-8</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429714#M106147</link>
      <description>&lt;P&gt;What happens if you use the filename reference instead of the file path?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;       &lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;import&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;file&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=fichCsv2&lt;/SPAN&gt; out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;outds
                   DBMS&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;DLM &lt;SPAN class="token keyword"&gt;REPLACE&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
				   Delimiter&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;';'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
                   Guessingrows&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;32767&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
                   Getnames&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;Yes&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
       &lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188321"&gt;@lavm01&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Libname Libsas 'E:\libsas\Itop';
Filename FichCsv2 'O:\Sc-Performance\PFI\ITOP\input_data\SCCM\Itop_Extraction_SCCM2012_lab.csv' ENCODING="utf-8";

%macro import_csv(outf,outds);
 %put outf=&amp;amp;outf;
 %let filrf=myfile;
 %put filrf=&amp;amp;filrf;
 %if %sysfunc(fileexist(&amp;amp;outf)) %then %do;
 %let rc=%sysfunc(filename(filrf,&amp;amp;outf));
 %let fid=%sysfunc(fopen(&amp;amp;filrf));
  %if &amp;amp;fid &amp;gt; 0 %then %do;
   %let rc=%sysfunc(fread(&amp;amp;fid));
   %let rc=%sysfunc(fget(&amp;amp;fid,mystring));
   %let rc_close=%sysfunc(fclose(&amp;amp;fid));
    %if &amp;amp;rc = 0 %then %do;
       proc import file="&amp;amp;outf." out=&amp;amp;outds
                   DBMS=DLM REPLACE;
				   Delimiter=';';
                   Guessingrows=32767;
                   Getnames=Yes;
       run;
    %end;
    %else %do;
      %put Fichier &amp;amp;outf. importation impossible fichier vide.;
	  Data _NULL_;
	   Date = today();
	   Format Date yymmdd10.;
	   File Sortie Notitles Mod;
	   put @50 "En date du: " Date +(-1)"," /;
	   put @10 "Le fichier &amp;amp;outf est vide.";
	  run;
	%end;
  %end;
 %let rc=%sysfunc(filename(filrf));
 %end;
 %else %put fichier existe pas;
%mend import_csv;



%import_csv(O:\Sc-Performance\PFI\ITOP\input_data\SCCM\Itop_Extraction_SCCM2012_lab.csv,Libsas.ItopSCCMLAB);
*%import_csv("&amp;amp;Fich2.",Libsas.ItopSCCMLAB);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Can not pass the filename with encoding. is there a way to pass him the filename or some other way because I have to keep the encoding.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 18:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429714#M106147</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-22T18:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem macro import_csv with filename encoding uft-8</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429719#M106150</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I know, I already tried that. Me it's more in the macro, the outf that does not recognize the encoding.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 18:14:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429719#M106150</guid>
      <dc:creator>lavm01</dc:creator>
      <dc:date>2018-01-22T18:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem macro import_csv with filename encoding uft-8</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429723#M106152</link>
      <description>&lt;PRE&gt;%import_csv(FichCsv2,Libsas.ItopSCCMLAB);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried with that but it does not work.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 18:17:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429723#M106152</guid>
      <dc:creator>lavm01</dc:creator>
      <dc:date>2018-01-22T18:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem macro import_csv with filename encoding uft-8</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429725#M106154</link>
      <description>&lt;P&gt;I can only comment on what you've posted.&lt;/P&gt;
&lt;P&gt;Your encoding is not&amp;nbsp;a parameter within PROC IMPORT that I can see, and you don't pass it in any form so I'm not sure what you're expecting. I don't see the encoding in the macro anywhere...and the section below - myfile is never defined within what you've posted so that may be problematic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could declare a filename statement within the macro and use that similar to the code I posted earlier, instead of passing the path to PROC IMPORT, pass the filename reference instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; &lt;SPAN class="token macrostatement"&gt;%put&lt;/SPAN&gt; outf&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;outf&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; filrf&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;myfile&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
 &lt;SPAN class="token macrostatement"&gt;%put&lt;/SPAN&gt; filrf&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;filrf&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188321"&gt;@lavm01&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;I know, I already tried that. Me it's more in the macro, the outf that does not recognize the encoding.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 18:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429725#M106154</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-22T18:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problem macro import_csv with filename encoding uft-8</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429731#M106158</link>
      <description>&lt;DIV class="tw-swapa"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="_Ejb"&gt;&lt;DIV&gt;&lt;DIV class="tw-ta-container tw-nfl"&gt;&lt;PRE class="tw-data-text tw-ta tw-text-small"&gt;&lt;SPAN&gt;I agree with you, but the marcro checks the file and also checks if it is possible to import the file. That is why the outf contains the path of the CSV as well as the encoding.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 Jan 2018 18:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429731#M106158</guid>
      <dc:creator>lavm01</dc:creator>
      <dc:date>2018-01-22T18:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem macro import_csv with filename encoding uft-8</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429741#M106165</link>
      <description>&lt;P&gt;The file exist portion doesn't need to change, they can be mutually exclusive events.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Add a parameter to the macro definition that can be the encoding.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Create a filename reference with the encoding, using the file reference and the encoding reference.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Check file exist - no change here.&lt;/LI&gt;
&lt;LI&gt;Change the&amp;nbsp;IMPORT step to use the filename reference instead of the filename.&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 22 Jan 2018 18:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429741#M106165</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-22T18:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problem macro import_csv with filename encoding uft-8</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429758#M106170</link>
      <description>&lt;P&gt;Your macro is already generating one or more steps, so just use a data step instead of macro code to call the various functions, (fileexist(),filename(),fopen(),etc.).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It will be a LOT easier to debug.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 19:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-macro-import-csv-with-filename-encoding-uft-8/m-p/429758#M106170</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-22T19:39:59Z</dc:date>
    </item>
  </channel>
</rss>

