<?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: how to check if an Excel file is empty before doing a proc import procedure in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/352142#M23233</link>
    <description>&lt;P&gt;Hello KSsharp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have try your solution and it works fine if your worksheet have at least the variable names in it.&amp;nbsp; I am not sure that it will works with a new excel file (empty).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help which is always apprecitated.&lt;/P&gt;&lt;P&gt;Alain&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2017 12:41:56 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2017-04-21T12:41:56Z</dc:date>
    <item>
      <title>how to check if an Excel file is empty before doing a proc import procedure</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/349432#M23051</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a macro that check if the excel file is empty or not before doing a proc import.&lt;/P&gt;&lt;P&gt;I am using Sas Enterprise Guide 5.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is the following.&amp;nbsp; Suppose that I first test if my excel file is empty.&lt;/P&gt;&lt;P&gt;There is only two possible answers : yes or no.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the file is empty do Steps A&lt;/P&gt;&lt;P&gt;Otherwise do Steps B.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to ckeck if the file exist first.&amp;nbsp; But how can I check if the Excel file (*.xlsx)&amp;nbsp;is empty before doing a proc import?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test(Dir=, FileName=);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; filrf=myfile;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%if&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(fileexist(&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;Dir.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;\&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;FileName.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%then&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; the file &amp;amp;FileName exist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; the file &amp;amp;FileName does not exist;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;test&lt;/I&gt;&lt;/STRONG&gt;(Dir=c:\Travail\Temp2\, FileName= File1.xlsx);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 13:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/349432#M23051</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2017-04-12T13:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if an Excel file is empty before doing a proc import procedure</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/349437#M23052</link>
      <description>&lt;P&gt;Define empty? &amp;nbsp;An xlsx file is never empty, and XLSX file is a ZIP file containing some folders, and some XML files at minimum. &amp;nbsp;I assume you mean that it contains no data yes? &amp;nbsp;If so just run the proc import, then test the dataset which is created - either as exist() function, or taking number of observations from the created dataset (can't remember if proc import creates and empty dataset for no data or not). &amp;nbsp;There's no direct way to ascertain numbe of observations before import, even libname to an xlsx file will do a sort of import.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2017 13:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/349437#M23052</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-12T13:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if an Excel file is empty before doing a proc import procedure</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/349455#M23056</link>
      <description>This is the correct way to go about it!</description>
      <pubDate>Wed, 12 Apr 2017 13:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/349455#M23056</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2017-04-12T13:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if an Excel file is empty before doing a proc import procedure</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/349467#M23057</link>
      <description>&lt;PRE&gt;
Check ANY attribute.



data x;
 set sashelp.class;
 stop;
run;

%let dsid=%sysfunc(open(x));
%let any=%sysfunc(attrn(&amp;amp;dsid,any));
%let dsid=%sysfunc(close(&amp;amp;dsid));

%put &amp;amp;any ;

&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Apr 2017 14:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/349467#M23057</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-12T14:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if an Excel file is empty before doing a proc import procedure</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/352142#M23233</link>
      <description>&lt;P&gt;Hello KSsharp,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have try your solution and it works fine if your worksheet have at least the variable names in it.&amp;nbsp; I am not sure that it will works with a new excel file (empty).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help which is always apprecitated.&lt;/P&gt;&lt;P&gt;Alain&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 12:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/352142#M23233</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2017-04-21T12:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to check if an Excel file is empty before doing a proc import procedure</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/352160#M23234</link>
      <description>&lt;PRE&gt;
The code will return different value according to you have no obs, no variable, both no obs and no variable.


&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 13:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/how-to-check-if-an-Excel-file-is-empty-before-doing-a-proc/m-p/352160#M23234</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-21T13:13:44Z</dc:date>
    </item>
  </channel>
</rss>

