<?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: Macro for reading multiple Excel Files in one Dataset     %macro w2sas05 in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493386#M15367</link>
    <description>&lt;P&gt;There isn't anything in that code which would restrict it as far as I can tell.&amp;nbsp; I would of course not recommend using Excel for data, and not using proc import for importing - the two together are terrible for getting data into any system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you are using 9.4 you can simplify it by using the xlsx libname to read/write Excel files:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/20/using-libname-xlsx-to-read-and-write-excel-files/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/05/20/using-libname-xlsx-to-read-and-write-excel-files/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This will simplify your code, but it does not remove the inherent bad data source, or guessing procedure import.&lt;/P&gt;
&lt;P&gt;You could then do something like:&lt;/P&gt;
&lt;PRE&gt;filename tmp pipe 'dir "c:/abc/*xlsx" /b';

data _null_;
  infile tmp;
  length temp $200;
  input temp $;
  call execute(cats('libname ex xlsx "c:/abc/',temp,'";'));
  call execute('proc copy in=ex out=work;run;');
  call execute('libname ex clear;');
run;&lt;/PRE&gt;
&lt;P&gt;This will open each file from the directory input, copy all sheets to work, then clear the libname.&amp;nbsp; You can add in any append code, maybe just append everything in work.&amp;nbsp; However as Excel is a bad data source, and you are guessing the data structure, you can be pretty sure that every run your append will fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Sep 2018 12:55:21 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-09-07T12:55:21Z</dc:date>
    <item>
      <title>Macro for reading multiple Excel Files in one Dataset     %macro w2sas05</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493379#M15365</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Using SAS 9.4 and Office 2016&lt;/P&gt;&lt;P&gt;I inherited a macro to combine multiple Excel files into one dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; w2sas05(input=P:\MICHC\CHW Data\&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2018&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;_Q3,out=work.Out);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dir=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(%'dir %")&amp;amp;input.&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(\%" /A-D/B/ON%');&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;filename myfiles pipe &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%unquote&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;dir);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;data list1; length fname &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$256.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;infile myfiles truncover;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;input myfiles &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$100.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;/* put infile;*/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;fname=quote(upcase(cats(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;input"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'\'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,myfiles)));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;drop myfiles;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;filename myfiles clear;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; j=1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dsid=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(open(list1));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rc=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(fetch(&amp;amp;dsid));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%while&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;rc=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; file=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(getvarc(&amp;amp;dsid,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(varnum(&amp;amp;dsid,fname))));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT DBMS=EXCEL OUT= _&amp;amp;j&lt;/P&gt;&lt;P&gt;DATAFILE= &amp;amp;file REPLACE ;&lt;/P&gt;&lt;P&gt;GETNAMES=YES;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;SHEET=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Out_WKST"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;MIXED=YES;&lt;/P&gt;&lt;P&gt;SCANTEXT=NO;&lt;/P&gt;&lt;P&gt;USEDATE=YES;&lt;/P&gt;&lt;P&gt;SCANTIME=YES;&lt;/P&gt;&lt;P&gt;DBSASLABEL=NONE;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _&amp;amp;j;&lt;/P&gt;&lt;P&gt;set _&amp;amp;j;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if Contractor = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; then delete;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc append data=_&amp;amp;j base=&amp;amp;out force; run;&lt;/P&gt;&lt;P&gt;proc delete data=_&amp;amp;j; run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rc=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(fetch(&amp;amp;dsid));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; j=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;j+1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rc=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(close(&amp;amp;dsid));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;%mend&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; w2sas05;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;w2sas05&lt;/I&gt;&lt;/STRONG&gt; (input=P:\MICHC\CHW Data\&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2018&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;_Q3,out=work.Out);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I run this macro for each worksheet in the Excel file. I recently updated the data booklet, and the macro is not reading the new variables. Do I need to change something in the excel files so the macro will call in all of the data? or do I need to tweak the SAS coding?&amp;nbsp; Thanks in advance for your help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Angela&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 12:43:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493379#M15365</guid>
      <dc:creator>AHeisey</dc:creator>
      <dc:date>2018-09-07T12:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for reading multiple Excel Files in one Dataset     %macro w2sas05</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493386#M15367</link>
      <description>&lt;P&gt;There isn't anything in that code which would restrict it as far as I can tell.&amp;nbsp; I would of course not recommend using Excel for data, and not using proc import for importing - the two together are terrible for getting data into any system.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you are using 9.4 you can simplify it by using the xlsx libname to read/write Excel files:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/20/using-libname-xlsx-to-read-and-write-excel-files/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/05/20/using-libname-xlsx-to-read-and-write-excel-files/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This will simplify your code, but it does not remove the inherent bad data source, or guessing procedure import.&lt;/P&gt;
&lt;P&gt;You could then do something like:&lt;/P&gt;
&lt;PRE&gt;filename tmp pipe 'dir "c:/abc/*xlsx" /b';

data _null_;
  infile tmp;
  length temp $200;
  input temp $;
  call execute(cats('libname ex xlsx "c:/abc/',temp,'";'));
  call execute('proc copy in=ex out=work;run;');
  call execute('libname ex clear;');
run;&lt;/PRE&gt;
&lt;P&gt;This will open each file from the directory input, copy all sheets to work, then clear the libname.&amp;nbsp; You can add in any append code, maybe just append everything in work.&amp;nbsp; However as Excel is a bad data source, and you are guessing the data structure, you can be pretty sure that every run your append will fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 12:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493386#M15367</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-07T12:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for reading multiple Excel Files in one Dataset     %macro w2sas05</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493468#M15376</link>
      <description>&lt;P&gt;Is the INPUT parameter correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IMO its not a good idea to include the parameter values in the macro definition, unless they're always the same I suppose or default.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you moved the files you need to update that path.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro w2sas05(input=P:\MICHC\CHW Data\2018_Q3, out=work.Out);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The only limit I'm aware of with Excel is sometimes there are issues when you have over 256 columns. Is that the case here?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/125187"&gt;@AHeisey&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Greetings,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: Using SAS 9.4 and Office 2016&lt;/P&gt;
&lt;P&gt;I inherited a macro to combine multiple Excel files into one dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; w2sas05(input=P:\MICHC\CHW Data\&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2018&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;_Q3,out=work.Out);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dir=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(%'dir %")&amp;amp;input.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(\%" /A-D/B/ON%');&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;filename myfiles pipe &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%unquote&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;dir);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;data list1; length fname &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;$256.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;infile myfiles truncover;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;input myfiles &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;$100.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#008000"&gt;/* put infile;*/&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;fname=quote(upcase(cats(&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"&amp;amp;input"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'\'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,myfiles)));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;drop myfiles;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;filename myfiles clear;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; j=1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dsid=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(open(list1));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rc=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(fetch(&amp;amp;dsid));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%do&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%while&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;rc=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; file=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(getvarc(&amp;amp;dsid,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(varnum(&amp;amp;dsid,fname))));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC IMPORT DBMS=EXCEL OUT= _&amp;amp;j&lt;/P&gt;
&lt;P&gt;DATAFILE= &amp;amp;file REPLACE ;&lt;/P&gt;
&lt;P&gt;GETNAMES=YES;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;SHEET=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"Out_WKST"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;MIXED=YES;&lt;/P&gt;
&lt;P&gt;SCANTEXT=NO;&lt;/P&gt;
&lt;P&gt;USEDATE=YES;&lt;/P&gt;
&lt;P&gt;SCANTIME=YES;&lt;/P&gt;
&lt;P&gt;DBSASLABEL=NONE;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _&amp;amp;j;&lt;/P&gt;
&lt;P&gt;set _&amp;amp;j;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if Contractor = &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;''&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; then delete;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc append data=_&amp;amp;j base=&amp;amp;out force; run;&lt;/P&gt;
&lt;P&gt;proc delete data=_&amp;amp;j; run;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rc=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(fetch(&amp;amp;dsid));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; j=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;j+1);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rc=&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(close(&amp;amp;dsid));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;%mend&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; w2sas05;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;w2sas05&lt;/I&gt;&lt;/STRONG&gt; (input=P:\MICHC\CHW Data\&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;2018&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;_Q3,out=work.Out);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I run this macro for each worksheet in the Excel file. I recently updated the data booklet, and the macro is not reading the new variables. Do I need to change something in the excel files so the macro will call in all of the data? or do I need to tweak the SAS coding?&amp;nbsp; Thanks in advance for your help!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Angela&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 14:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493468#M15376</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-07T14:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for reading multiple Excel Files in one Dataset     %macro w2sas05</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493484#M15382</link>
      <description>&lt;P&gt;Thanks for the replies. After digging deeper, I realized the macro was reading&amp;nbsp;hidden worksheets that needed to be updated with the new variables.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 15:08:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493484#M15382</guid>
      <dc:creator>AHeisey</dc:creator>
      <dc:date>2018-09-07T15:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for reading multiple Excel Files in one Dataset     %macro w2sas05</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493500#M15388</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/125187"&gt;@AHeisey&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I run this macro for each worksheet in the Excel file. I recently updated the data booklet, and the macro is not reading the new variables. Do I need to change something in the excel files so the macro will call in all of the data? or do I need to tweak the SAS coding?&amp;nbsp; Thanks in advance for your help!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Angela&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;By "new variables" do you mean that some of the sheets have different column headings/ numbers of columns of populated data?&lt;/P&gt;
&lt;P&gt;Proc APPEND will not add additional variables to the "base" data set from a "data" data set. You would have to use a data step with two or more data sets on the SET statement or some potentially very ugly proc sql code.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 15:24:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/493500#M15388</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-07T15:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for reading multiple Excel Files in one Dataset     %macro w2sas05</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/495532#M15444</link>
      <description>&lt;P&gt;The only limit I'm aware of with Excel is sometimes there are issues when you have over 256 columns. Is that the case here?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was not the original issue. But this is another issue. Is there a way to tell SAS to read more columns?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help&lt;/P&gt;&lt;P&gt;Angela&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 21:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/495532#M15444</guid>
      <dc:creator>AHeisey</dc:creator>
      <dc:date>2018-09-13T21:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for reading multiple Excel Files in one Dataset     %macro w2sas05</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/495603#M15446</link>
      <description>&lt;P&gt;Use a modern engine like the one I presented in my post, older engines have limitations based on the limitations of the software at that point.&amp;nbsp; Excel is a really bad format at the best of times, but using an old format of it just compounds the problem, as does using proc import to read it.&lt;/P&gt;
&lt;P&gt;Bad data source + guessing procedure = garbage out.&lt;/P&gt;
&lt;P&gt;Maxims 3, 11, 14, 22&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 08:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Macro-for-reading-multiple-Excel-Files-in-one-Dataset-macro/m-p/495603#M15446</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-14T08:12:30Z</dc:date>
    </item>
  </channel>
</rss>

