<?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: Proc Import - empty spreadsheet in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52783#M14520</link>
    <description>Yes.Art.T&lt;BR /&gt;
I also found this interest thing I have not imagined.&lt;BR /&gt;
So I try to fix and recode it.&lt;BR /&gt;
How about this:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
libname _xls excel path="c:\t.xls" getnames=no mixed=yes scantext=yes ;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select *&lt;BR /&gt;
   from _xls.'Sheet3$'n &lt;BR /&gt;
    where f1 is not missing;&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 %put NOTE: The number  is &amp;amp;sqlobs.;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Wed, 20 Apr 2011 04:08:31 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-04-20T04:08:31Z</dc:date>
    <item>
      <title>Proc Import - empty spreadsheet</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52779#M14516</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have several excel workbook with multiple sheets that I'm dynamically loading.  I have a couple of the workbooks that have a spreadsheets that are blank.  This fails to load correctly as the dataset has no rows but does get created with data issues.  I've tried %sysfunc(exist( but doesn't work correctly as the dataset does get created.  How can I get this to work?  I tried using an array to check and set a variable to skip it also.  The array says the array is empty and stops. &lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
set &amp;amp;&amp;amp;sheet&amp;amp;i;&lt;BR /&gt;
	array _c{*} _character_;&lt;BR /&gt;
	array _n{*} _numeric_;&lt;BR /&gt;
if missing(coalesceC(of _c{*})) and missing(coalesce(of _n{*})) then do;&lt;BR /&gt;
	call symputx('emptyds','Y');&lt;BR /&gt;
end;&lt;BR /&gt;
else do;&lt;BR /&gt;
	call symputx('emptyds','N');&lt;BR /&gt;
end; &lt;BR /&gt;
run;</description>
      <pubDate>Mon, 18 Apr 2011 21:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52779#M14516</guid>
      <dc:creator>summer7</dc:creator>
      <dc:date>2011-04-18T21:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import - empty spreadsheet</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52780#M14517</link>
      <description>You might be able to solve your problem via using the excel engine in a libname statement.  When I tried the following code, a blank spreadsheet was shown with one column, namely F1.  As such, the code borrowed from support.sas.com allowed one to see if such a variable exists.  As long as your real data doesn't contain such a variable, it might provide the basis of a solution:&lt;BR /&gt;
&lt;BR /&gt;
libname t1 "c:\test.xls";&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  dsid=open("t1.'sheet1$'n");&lt;BR /&gt;
  check=varnum(dsid,'f1');&lt;BR /&gt;
  if check=0 then put 'Variable does not exist';&lt;BR /&gt;
  else put 'Variable is located in column ' check +(-1) '.';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art&lt;BR /&gt;
-----------&lt;BR /&gt;
&amp;gt; Hi,&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; I have several excel workbook with multiple sheets&lt;BR /&gt;
&amp;gt; that I'm dynamically loading.  I have a couple of the&lt;BR /&gt;
&amp;gt; workbooks that have a spreadsheets that are blank.&lt;BR /&gt;
&amp;gt; This fails to load correctly as the dataset has no&lt;BR /&gt;
&amp;gt; rows but does get created with data issues.  I've&lt;BR /&gt;
&amp;gt; tried %sysfunc(exist( but doesn't work correctly as&lt;BR /&gt;
&amp;gt; the dataset does get created.  How can I get this to&lt;BR /&gt;
&amp;gt; work?  I tried using an array to check and set a&lt;BR /&gt;
&amp;gt; variable to skip it also.  The array says the array&lt;BR /&gt;
&amp;gt;  is empty and stops. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; data _null_;&lt;BR /&gt;
&amp;gt; set &amp;amp;&amp;amp;sheet&amp;amp;i;&lt;BR /&gt;
&amp;gt; 	array _c{*} _character_;&lt;BR /&gt;
&amp;gt; 	array _n{*} _numeric_;&lt;BR /&gt;
&amp;gt; if missing(coalesceC(of _c{*})) and&lt;BR /&gt;
&amp;gt; missing(coalesce(of _n{*})) then do;&lt;BR /&gt;
&amp;gt; 	call symputx('emptyds','Y');&lt;BR /&gt;
&amp;gt; end;&lt;BR /&gt;
&amp;gt; else do;&lt;BR /&gt;
&amp;gt; 	call symputx('emptyds','N');&lt;BR /&gt;
&amp;gt; end; &lt;BR /&gt;
&amp;gt; run;</description>
      <pubDate>Mon, 18 Apr 2011 21:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52780#M14517</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-04-18T21:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import - empty spreadsheet</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52781#M14518</link>
      <description>Maybe You can code like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
libname _xls excel path="c:\t.xls";&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select *&lt;BR /&gt;
   from _xls.'Sheet2$'n ;&lt;BR /&gt;
&lt;BR /&gt;
 %put NOTE: The number of obs in Sheet2  is &amp;amp;sqlobs.;&lt;BR /&gt;
quit;&lt;BR /&gt;
 /*%if &amp;amp;sqlobs. ne 0 %then %do;&lt;BR /&gt;
                            proc import......;&lt;BR /&gt;
                           %end; */&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 19 Apr 2011 07:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52781#M14518</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-19T07:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import - empty spreadsheet</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52782#M14519</link>
      <description>Ksharp,&lt;BR /&gt;
&lt;BR /&gt;
The interesting part about this case is that the record will appear as having one observation even though it, in fact, is an empty spreadsheet.&lt;BR /&gt;
&lt;BR /&gt;
Art&lt;BR /&gt;
----------&lt;BR /&gt;
&amp;gt; Maybe You can code like this:&lt;BR /&gt;
&amp;gt; [pre]&lt;BR /&gt;
&amp;gt; libname _xls excel path="c:\t.xls";&lt;BR /&gt;
&amp;gt; proc sql;&lt;BR /&gt;
&amp;gt;   select *&lt;BR /&gt;
&amp;gt;  from _xls.'Sheet2$'n ;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %put NOTE: The number of obs in Sheet2  is&lt;BR /&gt;
&amp;gt;  &amp;amp;sqlobs.;&lt;BR /&gt;
&amp;gt; uit;&lt;BR /&gt;
&amp;gt;  /*%if &amp;amp;sqlobs. ne 0 %then %do;&lt;BR /&gt;
&amp;gt;                            proc import......;&lt;BR /&gt;
&amp;gt; %end; */&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; [/pre]&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Ksharp</description>
      <pubDate>Tue, 19 Apr 2011 12:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52782#M14519</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-04-19T12:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import - empty spreadsheet</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52783#M14520</link>
      <description>Yes.Art.T&lt;BR /&gt;
I also found this interest thing I have not imagined.&lt;BR /&gt;
So I try to fix and recode it.&lt;BR /&gt;
How about this:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
libname _xls excel path="c:\t.xls" getnames=no mixed=yes scantext=yes ;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select *&lt;BR /&gt;
   from _xls.'Sheet3$'n &lt;BR /&gt;
    where f1 is not missing;&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
 %put NOTE: The number  is &amp;amp;sqlobs.;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 20 Apr 2011 04:08:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52783#M14520</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-20T04:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import - empty spreadsheet</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52784#M14521</link>
      <description>Thanks all for your suggestions.  I did try them all but had unexpected results.  I think this was due to the fact that the header row and start row was down several rows instead of the default of 1.  This is what I found that worked.  &lt;BR /&gt;
&lt;BR /&gt;
proc import datafile = "c:\temp\test.xls" out = test1(WHERE=(Not(missing(var1) AND missing(var2) AND missing(var3) AND missing(var4)) dbms=xls replace;&lt;BR /&gt;
			sheet = "testit";&lt;BR /&gt;
			namerow = 4;&lt;BR /&gt;
			startrow = 5;&lt;BR /&gt;
			guessingrows=16000;&lt;BR /&gt;
		run;&lt;BR /&gt;
&lt;BR /&gt;
and then I did a test for if it existed.  It would create a blank work dataset.  I would test for a zero row count and then ignore it if it was blank.&lt;BR /&gt;
&lt;BR /&gt;
%if %sysfunc(exist(test1)) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
	proc sql noprint;&lt;BR /&gt;
	   select count(*) into :xobs from test1;&lt;BR /&gt;
	quit;&lt;BR /&gt;
	%if &amp;amp;&amp;amp;xobs=0 %then %do;&lt;BR /&gt;
               ..... do something ..............&lt;BR /&gt;
	&lt;BR /&gt;
	%end;

Message was edited by: summer7</description>
      <pubDate>Tue, 26 Apr 2011 15:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52784#M14521</guid>
      <dc:creator>summer7</dc:creator>
      <dc:date>2011-04-26T15:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import - empty spreadsheet</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52785#M14522</link>
      <description>"The array says the array is empty and stops." &lt;BR /&gt;
&lt;BR /&gt;
extend the definition of the array with constants to guarantee something is present, like&lt;BR /&gt;
array _c{*} _character_ __empty  ; retain __empty ' ' ; &lt;BR /&gt;
array _n{*} _numeric_ __empN ;  retain __empN . ;</description>
      <pubDate>Tue, 24 May 2011 22:33:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Import-empty-spreadsheet/m-p/52785#M14522</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-05-24T22:33:32Z</dc:date>
    </item>
  </channel>
</rss>

