<?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: How to load excel with multiple sheets dynamically into SAS datset? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751421#M80733</link>
    <description>&lt;P&gt;A libname using the xlsx engine will allow you to access the sheets directly like SAS tables under a single libref. Example &lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/20/using-libname-xlsx-to-read-and-write-excel-files/" target="_self"&gt;here&lt;/A&gt; in one of Chris Hemedinger's fantastic blogs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You then can just use a proc datasets/copy to copy all these Excel sheets to another libref which uses the SAS engine - and they will "magically" become SAS tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure how you intend to deal with such "random" tables - is it only the names or will also the table structures differ - but you don't provide the information to make any further statements.&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jul 2021 10:21:03 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-07-01T10:21:03Z</dc:date>
    <item>
      <title>How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751415#M80732</link>
      <description>&lt;P&gt;I have an excel workbook which contains random sheets every month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As such, I want to have a script to load this excel workbook without hardcode any of the worksheet name inside the script. Is there a way in SAS where I can get the list of all sheets in the excel?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way, I can assign the list to macro and easily store in SAS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 09:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751415#M80732</guid>
      <dc:creator>StickyRoll</dc:creator>
      <dc:date>2021-07-01T09:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751421#M80733</link>
      <description>&lt;P&gt;A libname using the xlsx engine will allow you to access the sheets directly like SAS tables under a single libref. Example &lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/20/using-libname-xlsx-to-read-and-write-excel-files/" target="_self"&gt;here&lt;/A&gt; in one of Chris Hemedinger's fantastic blogs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You then can just use a proc datasets/copy to copy all these Excel sheets to another libref which uses the SAS engine - and they will "magically" become SAS tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure how you intend to deal with such "random" tables - is it only the names or will also the table structures differ - but you don't provide the information to make any further statements.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 10:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751421#M80733</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-07-01T10:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751424#M80734</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I dont see how this tutorial show us how SAS dynamically read all excel sheets/tabs automatically. I understand that I can use libname XLSX engine to read excel.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have an excel workbook that contains 5 sheets/tabs. I don't want to hardcode the sheets/tabs in any part of the SAS script. What I want is to automatically load in all excel sheets as tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I have 5 sheets, I want to create 5 datasets, all without hardcode the actual name of the excel sheets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 10:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751424#M80734</guid>
      <dc:creator>StickyRoll</dc:creator>
      <dc:date>2021-07-01T10:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751426#M80735</link>
      <description>&lt;P&gt;here is my code:&lt;/P&gt;&lt;PRE&gt;libname xl XLSX "D:\Excel.xlsx;


proc contents data=xl._ALL_;

RUN;

&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get a warning&lt;/P&gt;&lt;PRE&gt;"no matching members in directory".&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, the sample in the tutorial shows 3 members which I believe is the sheets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why is this happening? My excel has 3 sheets as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 11:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751426#M80735</guid>
      <dc:creator>StickyRoll</dc:creator>
      <dc:date>2021-07-01T11:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751429#M80736</link>
      <description>&lt;P&gt;Here is my modification that works for me, and also allows sheet names and variable names to have special characters or blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname xl XLSX "D:\Excel.xlsx";

options validvarname=v7;

proc copy in=xl out=work memtype=data;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, may I make a request&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/376676"&gt;@StickyRoll&lt;/a&gt;&amp;nbsp;? From now on please paste the actual code (or better yet, paste the log so we can see the code and the ERRORs, WARNINGs and NOTEs) into your message. The code you showed cannot possibly work, because your LIBNAME statement is wrong, and is missing a double quote after the .xlsx, and that could be the cause of the error you are seeing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 11:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751429#M80736</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-01T11:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751437#M80737</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this warning:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;28         libname xl XLSX "D:\SASexcel.xlsx"; 
NOTE: Libref XL was successfully assigned as follows: 
      Engine:        XLSX 
      Physical Name: D:\SASexcel.xlsx
29         
30         options validvarname=V7;


31         proc copy in=xl out=work memtype=data;
32         run;

WARNING: Input library XL is empty.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My script as below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname xl XLSX "D:\SASexcel.xlsx"; 

options validvarname=V7;
proc copy in=xl out=work memtype=data;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think SAS couldn't read my excel sheets/tabs. Not sure what caused that. Did you see anything wrong with my script?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 12:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751437#M80737</guid>
      <dc:creator>StickyRoll</dc:creator>
      <dc:date>2021-07-01T12:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751439#M80738</link>
      <description>&lt;P&gt;Does the file&amp;nbsp;D:\SASexcel.xlsx actually exist? The message you are getting is the same message I get when I use a LIBNAME that points to an Excel file that doesn't exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 12:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751439#M80738</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-01T12:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751440#M80739</link>
      <description>&lt;P&gt;Most likely the path you have for the filename does not exists.&amp;nbsp; SAS does not know that you intend to READ from that new XL libref. You might be intending to create a new XLSX file so that you can WRITE to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure the file exists.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  filename = "D:\SASexcel.xlsx"; 
  if fileexist(filename) then put filename=:$quote. 'exists.';
  else put filename=:$quote. 'does NOT exist.';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jul 2021 12:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751440#M80739</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-01T12:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to load excel with multiple sheets dynamically into SAS datset?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751441#M80740</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Spot on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to delete the excel and create a dummy excel. Using the script provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;worked like a charm with the new excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;for the help. Appreciate it.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 12:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-load-excel-with-multiple-sheets-dynamically-into-SAS/m-p/751441#M80740</guid>
      <dc:creator>StickyRoll</dc:creator>
      <dc:date>2021-07-01T12:49:02Z</dc:date>
    </item>
  </channel>
</rss>

