<?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 read xlsx file only if it exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57814#M12521</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Add a RUN; statement to each of your CALL EXECUTE steps.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The second CALL EXECUTE could be simplified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if fileexist("c:\test.xlsx") then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc import datafile="c:\test.xlsx" out=work.lixi dbms=excelcs replace;run;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('data lixi;stop;wingband=.;run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Feb 2012 19:56:08 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2012-02-17T19:56:08Z</dc:date>
    <item>
      <title>How to read xlsx file only if it exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57813#M12520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to write some SAS code that will read in a .xlsx file if it exists, otherwise I would like it to create an empty dataset.&amp;nbsp; I've written some code but it hangs at the "call execute" line.&amp;nbsp; Here is what I am trying:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if fileexist("c:\test.xlsx") then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc import datafile="c:\test.xlsx" out=work.lixi dbms=excelcs replace;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('data lixi;infile datalines;input wingband;datalines;;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&amp;nbsp; Is there a better way to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 19:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57813#M12520</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2012-02-17T19:39:22Z</dc:date>
    </item>
    <item>
      <title>How to read xlsx file only if it exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57814#M12521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Add a RUN; statement to each of your CALL EXECUTE steps.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The second CALL EXECUTE could be simplified.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if fileexist("c:\test.xlsx") then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc import datafile="c:\test.xlsx" out=work.lixi dbms=excelcs replace;run;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('data lixi;stop;wingband=.;run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 19:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57814#M12521</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-02-17T19:56:08Z</dc:date>
    </item>
    <item>
      <title>How to read xlsx file only if it exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57815#M12522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Art.&amp;nbsp; However, it SAS still hangs at the first call execute statement.&amp;nbsp; Here is what I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if fileexist("c:\test.xlsx") then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('proc import datafile="c:\test.xlsx" out=work.lixi dbms=excelcs replace;run;');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call execute('data lixi;stop;wingband=.;run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 20:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57815#M12522</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2012-02-17T20:33:34Z</dc:date>
    </item>
    <item>
      <title>How to read xlsx file only if it exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57816#M12523</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just run the import without the rest.&amp;nbsp; Does it still hang?&lt;/P&gt;&lt;P&gt;If not then try writing the code to a file instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;filename code temp;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;data _null_;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; file code;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; if fileexist("c:\test.xlsx") then&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put 'proc import datafile="c:\test.xlsx" out=work.lixi dbms=excelcs replace;run;' ;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp; else&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put 'data lixi;stop;wingband=.;run;';&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;run;&lt;/P&gt;&lt;P style="background-color: #eef4f9;"&gt;%inc code / source2 ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 20:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57816#M12523</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-02-17T20:36:22Z</dc:date>
    </item>
    <item>
      <title>How to read xlsx file only if it exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57817#M12524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it still hung.&amp;nbsp; I ended up copying that file and pasting as a new file and the SAS code worked.&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57817#M12524</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2012-02-17T21:41:26Z</dc:date>
    </item>
    <item>
      <title>How to read xlsx file only if it exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57818#M12525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Try changing the DBMS to DMBS=EXCEL rather than EXCELCS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57818#M12525</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-02-17T21:55:13Z</dc:date>
    </item>
    <item>
      <title>How to read xlsx file only if it exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57819#M12526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Art,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I change DBMS=EXCELCS to DBMS=EXCEL, I get this error in the log:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: DBMS type EXCEL not valid for import.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I was trying to get this to work by trial-and-error I stumbled across&lt;/P&gt;&lt;P&gt;DBMS=EXCELCS.&amp;nbsp; It was the only DBMS that worked for me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 14:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57819#M12526</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2012-02-20T14:52:01Z</dc:date>
    </item>
    <item>
      <title>How to read xlsx file only if it exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57820#M12527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I have not used EXCELCS, but I did find this SAS note.&amp;nbsp; Not the same but it might be related.&amp;nbsp; Under some versions of SAS .XLSX can be a problem while .XLS is not.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/37/479.html"&gt;http://support.sas.com/kb/37/479.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 17:08:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-xlsx-file-only-if-it-exists/m-p/57820#M12527</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-02-20T17:08:05Z</dc:date>
    </item>
  </channel>
</rss>

