<?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: read dir all for all xlsx with blank to important all files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/read-dir-all-for-all-xlsx-with-blank-to-important-all-files/m-p/294366#M61412</link>
    <description>&lt;P&gt;Simplfying your code will help you. &amp;nbsp;Also note it is never a good idea to have any special characters in filenames or paths.&lt;/P&gt;
&lt;PRE&gt;filename lib pipe 'dir "C:\SASMACRO\data\F2+Blank\*.xlsx" /b';

data file;
  infile lib truncover;
  input;
  call execute('proc import datafile="C:\SASMACRO\data\F2+Blank\"'||strip(_infile_)||'" out=inter dbms=xlsx; run;');
  call execute('data want; set want inter; run;');&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;You will note that&amp;nbsp;each iteration creates inter, then that gets set to want (want should be created before this step!). &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 26 Aug 2016 12:45:08 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-08-26T12:45:08Z</dc:date>
    <item>
      <title>read dir all for all xlsx with blank to important all files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-dir-all-for-all-xlsx-with-blank-to-important-all-files/m-p/294362#M61409</link>
      <description>&lt;P&gt;I have wirte a macro to important all xlsx in&amp;nbsp;&lt;SPAN&gt;"C:\SASMACRO\data\F2+Blank\" and read them and merged in a dataset called "a."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I have problems is that the file dataset with one variable (filenames), which cannot read the blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, if a xlsx data called "data 01", then it cannot read.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can some one help me to improve the problems that I can important xlsx file with blank in its name.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thx.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro merge();&lt;BR /&gt;proc sql noprint;select count(filenames) INTO :myn from File;&lt;BR /&gt;%do i=1 %to &amp;amp;myn;&lt;BR /&gt;proc import out=datafile&amp;amp;i datafile="&amp;amp;&amp;amp;file&amp;amp;i" dbms=xlsx /*any data type*/replace;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;data a;&lt;BR /&gt;set %do j=1 %to &amp;amp;myn;&lt;BR /&gt;datafile&amp;amp;j&lt;BR /&gt;%end;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;%mend merge;&lt;BR /&gt;filename lib pipe 'dir "C:\SASMACRO\data\F2+Blank\*.xlsx" /b';&lt;BR /&gt;data file;&lt;BR /&gt;length filenames $ 40;&lt;BR /&gt;infile lib truncover;&lt;BR /&gt;input filenames : $;&lt;BR /&gt;filenames="C:\SASMACRO\data\F2+Blank\"||filenames;&lt;BR /&gt;run;&lt;BR /&gt;data _NULL_;&lt;BR /&gt;set file;&lt;BR /&gt;call symputx('file'||put(_n_,1.),filenames,'G');&lt;BR /&gt;run;&lt;BR /&gt;options sasautos=work;&lt;BR /&gt;%merge() &lt;BR /&gt;/*data would be merged in a*/&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 12:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-dir-all-for-all-xlsx-with-blank-to-important-all-files/m-p/294362#M61409</guid>
      <dc:creator>ffgsdf</dc:creator>
      <dc:date>2016-08-26T12:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: read dir all for all xlsx with blank to important all files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/read-dir-all-for-all-xlsx-with-blank-to-important-all-files/m-p/294366#M61412</link>
      <description>&lt;P&gt;Simplfying your code will help you. &amp;nbsp;Also note it is never a good idea to have any special characters in filenames or paths.&lt;/P&gt;
&lt;PRE&gt;filename lib pipe 'dir "C:\SASMACRO\data\F2+Blank\*.xlsx" /b';

data file;
  infile lib truncover;
  input;
  call execute('proc import datafile="C:\SASMACRO\data\F2+Blank\"'||strip(_infile_)||'" out=inter dbms=xlsx; run;');
  call execute('data want; set want inter; run;');&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;You will note that&amp;nbsp;each iteration creates inter, then that gets set to want (want should be created before this step!). &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2016 12:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/read-dir-all-for-all-xlsx-with-blank-to-important-all-files/m-p/294366#M61412</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-26T12:45:08Z</dc:date>
    </item>
  </channel>
</rss>

