<?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: SAS Fileexist Query in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Fileexist-Query/m-p/485060#M125988</link>
    <description>&lt;P&gt;Your call to FILEEXIST() is looking for a different file than you are using in your PROC IMPORT code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;num eq 1 or %sysfunc(fileexist(&amp;amp;brand_.xlsx)) %then %do;
PROC IMPORT OUT=brand DATAFILE="D:\&amp;amp;brand..xlsx"
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first one is using a macro variable name BRAND_ and the second is using a macro variable named BRAND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top part of your program is a little confusing also.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to concatenate all of the values of BRAND into a single macro variable?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you expect your input dataset to have only one value of BRAND?&lt;/P&gt;
&lt;P&gt;Or are you trying to loop over the lists of brands in the dataset and import multiple XLSX files?&lt;/P&gt;</description>
    <pubDate>Wed, 08 Aug 2018 09:38:34 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-08-08T09:38:34Z</dc:date>
    <item>
      <title>SAS Fileexist Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Fileexist-Query/m-p/485058#M125987</link>
      <description>&lt;P&gt;I run the below codes but could not import the external file despite meeting the criteria.&amp;nbsp; Anyone can help? Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input brand $;&lt;BR /&gt;cards;&lt;BR /&gt;BMW&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select distinct brand&lt;BR /&gt;into :brand separated by ''&lt;BR /&gt;from test;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dsid=%sysfunc(open(test));&lt;BR /&gt;%let num=%sysfunc(attrn(&amp;amp;dsid,nobs));&lt;BR /&gt;%let rc=%sysfunc(close(&amp;amp;dsid));&lt;/P&gt;&lt;P&gt;%put &amp;amp;dsid;&lt;BR /&gt;%put &amp;amp;num;&lt;BR /&gt;%put &amp;amp;rc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/**if number of row = 1 and excel file exist**/&lt;BR /&gt;%macro checkds;&lt;BR /&gt;%if &amp;amp;num eq 1 or %sysfunc(fileexist(&amp;amp;brand_.xlsx)) %then %do;&lt;BR /&gt;PROC IMPORT OUT=brand&lt;BR /&gt;DATAFILE="D:\&amp;amp;brand..xlsx"&lt;BR /&gt;DBMS=EXCEL REPLACE;&lt;BR /&gt;GETNAMES=YES;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;stop;&lt;BR /&gt;%end;&lt;BR /&gt;%mend checkds;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 09:28:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Fileexist-Query/m-p/485058#M125987</guid>
      <dc:creator>scb</dc:creator>
      <dc:date>2018-08-08T09:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Fileexist Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Fileexist-Query/m-p/485060#M125988</link>
      <description>&lt;P&gt;Your call to FILEEXIST() is looking for a different file than you are using in your PROC IMPORT code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;num eq 1 or %sysfunc(fileexist(&amp;amp;brand_.xlsx)) %then %do;
PROC IMPORT OUT=brand DATAFILE="D:\&amp;amp;brand..xlsx"
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first one is using a macro variable name BRAND_ and the second is using a macro variable named BRAND.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top part of your program is a little confusing also.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to concatenate all of the values of BRAND into a single macro variable?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you expect your input dataset to have only one value of BRAND?&lt;/P&gt;
&lt;P&gt;Or are you trying to loop over the lists of brands in the dataset and import multiple XLSX files?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 09:38:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Fileexist-Query/m-p/485060#M125988</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-08T09:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Fileexist Query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Fileexist-Query/m-p/485067#M125991</link>
      <description>&lt;P&gt;So, your using a guessing procedure to guess what the data should like as you don't know.&amp;nbsp; You are using the worst possible data format file which has no structural rigidity.&amp;nbsp; And then to compound it you don't even know if the file exists?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And this process is going to work? (clue, answer is no it will not work).&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 10:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Fileexist-Query/m-p/485067#M125991</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-08T10:16:02Z</dc:date>
    </item>
  </channel>
</rss>

