<?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 check names of excel sheets in SAS in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/594895#M8128</link>
    <description>&lt;P&gt;How to check names of excel sheets in order?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used proc datasets lib= option&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the sheet names appear in alphabetical order.&lt;/P&gt;&lt;P&gt;How to get the names in the same order as they appear in excel sheet?&lt;/P&gt;</description>
    <pubDate>Tue, 08 Oct 2019 20:48:45 GMT</pubDate>
    <dc:creator>Ayisha</dc:creator>
    <dc:date>2019-10-08T20:48:45Z</dc:date>
    <item>
      <title>How to check names of excel sheets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/594895#M8128</link>
      <description>&lt;P&gt;How to check names of excel sheets in order?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used proc datasets lib= option&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the sheet names appear in alphabetical order.&lt;/P&gt;&lt;P&gt;How to get the names in the same order as they appear in excel sheet?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 20:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/594895#M8128</guid>
      <dc:creator>Ayisha</dc:creator>
      <dc:date>2019-10-08T20:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to check names of excel sheets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/594918#M8129</link>
      <description>&lt;P&gt;I believe this information doesn't get read into SAS. Given that you could also read ranges instead of sheets and that there could be more than one range per sheet (=multiple SAS tables reading data from the same sheet) I also don't see how SAS could reasonably store such information.&lt;/P&gt;
&lt;P&gt;If you really need the order of the sheets within the Excel then I guess you would need some VB script (or similar) which extracts the information and then read this into a separate SAS table. What's possible depends on the OS of your SAS server and if you can issue OS level commands (=option XCMD must be set).&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2019 23:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/594918#M8129</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-10-08T23:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to check names of excel sheets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/595026#M8131</link>
      <description>&lt;P&gt;libname x xlsx 'c:\temp\x.xlsx';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;select *&lt;/P&gt;
&lt;P&gt;&amp;nbsp;from dictionary.tables&lt;/P&gt;
&lt;P&gt;&amp;nbsp; where libname='X' ;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 12:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/595026#M8131</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-09T12:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to check names of excel sheets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/595048#M8132</link>
      <description>&lt;P&gt;Just read the information from the XLSX file yourself.&amp;nbsp; An XSLX file is just a ZIP file that contains a lot of XML files. The lists of sheet names is in the XML file named xl/workbook.xml.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that you will need to copy the file out of the workbook and into a new physical file for the XMLV2 engine to read from it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I made a little workbook with three sheets and then moved the order of them around and saved it to disk. Then I ran this code to pull out the list of sheets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*----------------------------------------------------------------------;
* Copy xl/workbook.xml from XLSX file to physical file ;
*----------------------------------------------------------------------;
filename _wbzip ZIP '3sheets.xlsx' member='xl/workbook.xml';
filename _wb temp ;
data _null_;
rc=fcopy('_wbzip','_wb');
run;

*----------------------------------------------------------------------;
* Generate LIBNAME pointing to copy of xl/workbook.xml from XLSX file ;
*----------------------------------------------------------------------;
filename _wbmap temp;
libname _wb xmlv2 xmlmap=_wbmap automap=reuse;

data sheet_names;
 set _wb.sheet;
run;
proc print width=min;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;       sheets_     sheet_                   sheet_
Obs    ORDINAL    ORDINAL    sheet_name    sheetId    sheet_id

 1        1          1       Was_Sheet3       3         rId1
 2        1          2       Was_Sheet1       1         rId2
 3        1          3       Was_Sheet2       2         rId3&lt;/PRE&gt;
&lt;P&gt;The variable SHEET_ORDINAL that the XMLV2 engine generated will have the order of the sheets.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 13:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/595048#M8132</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-09T13:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to check names of excel sheets in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/688090#M9409</link>
      <description>&lt;P&gt;Thanks for this&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 03:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-check-names-of-excel-sheets-in-SAS/m-p/688090#M9409</guid>
      <dc:creator>shreyvirmani</dc:creator>
      <dc:date>2020-10-01T03:20:17Z</dc:date>
    </item>
  </channel>
</rss>

