<?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: Importing multiple Excel files in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724215#M38304</link>
    <description>&lt;P&gt;Write your code in a manner that makes data step code vs. macro code visible:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data whole;
set
%do j=1 %to &amp;amp;n;
  datafile&amp;amp;j
%end;
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 Mar 2021 21:42:58 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-03-06T21:42:58Z</dc:date>
    <item>
      <title>Importing multiple Excel files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724088#M38300</link>
      <description>&lt;P&gt;I have been using following code to import multiple excel files. But today its giving me this error -&amp;nbsp;ERROR: File WORK.RUN.DATA does not exist. Tries looking up here but unable to resolve. Following is the code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;----------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;options mprint mlogic symbolgen;&lt;/P&gt;
&lt;P&gt;%macro merge(n);&amp;nbsp;&lt;BR /&gt;%do i=1 %to &amp;amp;n;&lt;BR /&gt;proc import out=datafile&amp;amp;i datafile="&amp;amp;&amp;amp;file&amp;amp;i" dbms=xlsx replace;&lt;BR /&gt;*sheet="xyz";&lt;BR /&gt;getnames=yes;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data whole;&lt;BR /&gt;set %do j=1 %to &amp;amp;n;&lt;BR /&gt;datafile&amp;amp;j&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%mend merge;&lt;/P&gt;
&lt;P&gt;filename lib pipe 'dir "E:\abc\*.xlsx" /b';&lt;BR /&gt;data _null_;&lt;BR /&gt;infile lib;&lt;BR /&gt;input;list;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data file;&lt;BR /&gt;length filenames $ 200;&lt;BR /&gt;infile lib truncover;&lt;BR /&gt;input filenames : $;&lt;BR /&gt;filenames="E:\abc\"||filenames;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data null;&lt;BR /&gt;set file;&lt;BR /&gt;call symputx('file'||put(_n_,8. -L ),filenames,'G');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;options sasautos=work;&lt;BR /&gt;%merge(10)&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 23:08:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724088#M38300</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2021-03-05T23:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724101#M38301</link>
      <description>&lt;P&gt;You have option MPRINT&amp;nbsp; MOLOGIC and SYMBOLGEN turned on. Good.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try using only fixing so that you are only reading two files as the parameter for the macro to reduce the length of the log.&lt;/P&gt;
&lt;P&gt;Show the LOG from running the macro. All of it. Copy and paste into a text box opened on the forum with the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most likely something is causing this:&lt;/P&gt;
&lt;PRE&gt;data whole;
set %do j=1 %to &amp;amp;n;
   datafile&amp;amp;j
%end;
run;&lt;/PRE&gt;
&lt;P&gt;to cause datafile&amp;amp;j to be undefined for all the j=1 %to &amp;amp;n.&lt;/P&gt;
&lt;P&gt;Which may point to a problem with&lt;/P&gt;
&lt;P&gt;filename lib pipe 'dir "E:\abc\*.xlsx" /b'; not finding any files the folder. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW you should not use this style of comment inside macros:&lt;/P&gt;
&lt;PRE&gt;*sheet="xyz";&lt;/PRE&gt;
&lt;P&gt;as they still get passed to the macro processor and sometimes "comments" get executed or mess with other code.&lt;/P&gt;
&lt;P&gt;use one of&lt;/P&gt;
&lt;PRE&gt;%*sheet="xyz";

/*sheet="xyz";*/&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Mar 2021 00:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724101#M38301</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-06T00:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724153#M38302</link>
      <description>&lt;PRE&gt;SYMBOLGEN:  Macro variable SASWORKLOCATION resolves to 
            "C:\Users\AppData\Roaming\SAS\EnterpriseGuide\EGTEMP\SEG-19596-7410e0f1\contents\SAS Temporary 
            Files\_TD32504_MGTAWATE18D_\Prc2/"
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                      
1         pubmed21n0060.xlsx 18
2         pubmed21n0061.xlsx 18
MLOGIC(MERGE):  Beginning execution.
MLOGIC(MERGE):  Parameter N has value 2
SYMBOLGEN:  Macro variable N resolves to 2

MLOGIC(MERGE):  %DO loop beginning; index variable I; start value is 1; stop value is 2; by value is 1.  
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable FILE1 resolves to E:\abc\pubmed21n0060.xlsx
MPRINT(MERGE):   proc import out=datafile1 datafile="E:\abc\pubmed21n0060.xlsx" dbms=xlsx replace;
MPRINT(MERGE):   RXLX;
MPRINT(MERGE):   getnames=yes;
MPRINT(MERGE):   run;


MLOGIC(MERGE):  %DO loop index variable I is now 2; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable FILE2 resolves to E:\abc\pubmed21n0061.xlsx
MPRINT(MERGE):   proc import out=datafile2 datafile="E:\abc\pubmed21n0061.xlsx" dbms=xlsx replace;
MPRINT(MERGE):   RXLX;
MPRINT(MERGE):   getnames=yes;
MPRINT(MERGE):   run;

MLOGIC(MERGE):  %DO loop index variable I is now 3; loop will not iterate again.
MPRINT(MERGE):   data whole;
SYMBOLGEN:  Macro variable N resolves to 2
MLOGIC(MERGE):  %DO loop beginning; index variable J; start value is 1; stop value is 2; by value is 1.  
SYMBOLGEN:  Macro variable J resolves to 1
MLOGIC(MERGE):  %DO loop index variable J is now 2; loop will iterate again.
SYMBOLGEN:  Macro variable J resolves to 2
MLOGIC(MERGE):  %DO loop index variable J is now 3; loop will not iterate again.
MPRINT(MERGE):   set datafile1 datafile2 run;
&lt;FONT color="#FF0000"&gt;ERROR: File WORK.RUN.DATA does not exist.&lt;/FONT&gt;
MLOGIC(MERGE):  Ending execution.
77         ;*';*";*/;quit;run;
                     ____
                     180
&lt;FONT color="#FF0000"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Mar 2021 15:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724153#M38302</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2021-03-06T15:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724214#M38303</link>
      <description>&lt;P&gt;Your SET statement misses a terminating semicolon, so the word run is considered to be the name of a dataset.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Mar 2021 18:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724214#M38303</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-06T18:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple Excel files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724215#M38304</link>
      <description>&lt;P&gt;Write your code in a manner that makes data step code vs. macro code visible:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data whole;
set
%do j=1 %to &amp;amp;n;
  datafile&amp;amp;j
%end;
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Mar 2021 21:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Importing-multiple-Excel-files/m-p/724215#M38304</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-06T21:42:58Z</dc:date>
    </item>
  </channel>
</rss>

