<?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 How to use SAS/SQL to count the number of EXCEL files in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247252#M56284</link>
    <description>&lt;P&gt;Suppose there are multiple EXCEL files under a file path. All the files have irregular names. Each file has multiple sheets, also irregularly named. &amp;nbsp; &amp;nbsp; &amp;nbsp;Now I want to use PROC SQL to count the number of EXCEL files under the file path, and the number of sheets in each different EXCEL file. &amp;nbsp; &amp;nbsp;How to do it? Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Waiting for the responses~~~&lt;/P&gt;</description>
    <pubDate>Mon, 01 Feb 2016 17:13:51 GMT</pubDate>
    <dc:creator>lxn1021</dc:creator>
    <dc:date>2016-02-01T17:13:51Z</dc:date>
    <item>
      <title>How to use SAS/SQL to count the number of EXCEL files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247252#M56284</link>
      <description>&lt;P&gt;Suppose there are multiple EXCEL files under a file path. All the files have irregular names. Each file has multiple sheets, also irregularly named. &amp;nbsp; &amp;nbsp; &amp;nbsp;Now I want to use PROC SQL to count the number of EXCEL files under the file path, and the number of sheets in each different EXCEL file. &amp;nbsp; &amp;nbsp;How to do it? Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Waiting for the responses~~~&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2016 17:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247252#M56284</guid>
      <dc:creator>lxn1021</dc:creator>
      <dc:date>2016-02-01T17:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SAS/SQL to count the number of EXCEL files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247254#M56285</link>
      <description>&lt;P&gt;You can't directly, SAS only looks at SAS related files. &amp;nbsp;However you can query the underlying Operating System with its commands, and feed the results back into SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename mylist pipe 'dir "c:\test\*.*" /b';&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; infile mylist;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; length buffer $2000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; input buffer;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then count the observations of dataset have to get number of files. &amp;nbsp;The filename is a dos command - dir - with a location paramter and /b means basic info - i.e. just a filename.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2016 17:26:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247254#M56285</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-01T17:26:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SAS/SQL to count the number of EXCEL files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247293#M56286</link>
      <description>&lt;P&gt;If you have the SAS product SAS/ACCESS to PC Files then it is possible to set up a LIBNAME to each Excel workbook and count up the number of sheets using the SAS DICTIONARY table MEMBERS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would take quite a bit of coding to get it working and it would ignore sheet names longer than 32 characters because that is the maximum SAS can handle via the DICTIONARY mechanism. I would probably take quite a while to run also if you have a lot of workbooks.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Feb 2016 19:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247293#M56286</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-02-01T19:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SAS/SQL to count the number of EXCEL files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247368#M56303</link>
      <description>&lt;P&gt;I tried the following&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let path=&amp;amp;sasforum.\datasets;

filename mylist pipe "dir ""&amp;amp;path.\*.xls*"" /b";

data _null_;
  infile mylist truncover;
  length buffer $2000;
  input buffer $2000.;
  i+1;
  length file line $1024;
  file = quote(catx("\", "&amp;amp;path.", buffer));
  lib_name = cats("xl_", i);
  line = catx(" ", "libname", lib_name, "Excel", file, " access=readonly;");
  *put line;
  call execute(line);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it stopped at libref=XL_64, giving errors after that. So it looks like you have to extract the sheet names one workbook at a time.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 03:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247368#M56303</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-02-02T03:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SAS/SQL to count the number of EXCEL files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247383#M56304</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, I didn't read that about Sheet names. &amp;nbsp;I would suggest the easiest way to do this would be to use VBA in Excel - use the right tech for the task. &amp;nbsp;It is a simple bit of code, outside of the scope of this forum however. &amp;nbsp;But google for:&lt;/P&gt;
&lt;P&gt;Open list of files in Excel&lt;/P&gt;
&lt;P&gt;&lt;A href="http://software-solutions-online.com/2014/03/05/list-files-and-folders-in-a-directory/" target="_blank"&gt;http://software-solutions-online.com/2014/03/05/list-files-and-folders-in-a-directory/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then simply loop over that list;&lt;/P&gt;
&lt;P&gt;for each cell in range[...]&lt;/P&gt;
&lt;P&gt;&amp;nbsp; open file&lt;/P&gt;
&lt;P&gt;&amp;nbsp; cell.offset(0,1).value=activeworkbook.sheets&lt;/P&gt;
&lt;P&gt;&amp;nbsp; close file&lt;/P&gt;
&lt;P&gt;close&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You then have a list of files, with number of sheets. &amp;nbsp;You could also output a list of sheet names if you. &amp;nbsp;VBA is pretty powerfull when using Excel. &amp;nbsp;Just google anything VBA excel &amp;lt;your topic&amp;gt; and there is lots of code available.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Feb 2016 09:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-SAS-SQL-to-count-the-number-of-EXCEL-files/m-p/247383#M56304</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-02T09:10:11Z</dc:date>
    </item>
  </channel>
</rss>

