<?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 import second sheet from Excel workbook in to SAS without mentioning Sheet name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694524#M211822</link>
    <description>&lt;P&gt;which option i need to change for reading .xls files&lt;/P&gt;</description>
    <pubDate>Tue, 27 Oct 2020 12:15:30 GMT</pubDate>
    <dc:creator>Padma_stat</dc:creator>
    <dc:date>2020-10-27T12:15:30Z</dc:date>
    <item>
      <title>How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669265#M200743</link>
      <description>I have Excel workbook with multiple sheets , I need to read second sheet in to SAS without mentioning sheet name. Why because I don't know what is the exact sheet name at second sheet in the excel workbook.&lt;BR /&gt;I have tried two methods&lt;BR /&gt;1. Proc impot method ( it need sheet name must)&lt;BR /&gt;2. Libname method (it reads all sheets from Excel workbook)&lt;BR /&gt;&lt;BR /&gt;Can any suggest to import only second sheet from Excel workbook.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance..</description>
      <pubDate>Tue, 14 Jul 2020 18:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669265#M200743</guid>
      <dc:creator>Padma_stat</dc:creator>
      <dc:date>2020-07-14T18:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669268#M200746</link>
      <description>With your libname connection, you should be able to find the 2nd sheet name using the sashelp.vtable dictionary view.</description>
      <pubDate>Tue, 14 Jul 2020 18:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669268#M200746</guid>
      <dc:creator>ketpt42</dc:creator>
      <dc:date>2020-07-14T18:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669273#M200749</link>
      <description>&lt;P&gt;You can find the NAMES of the sheets using the libname engine, but not their order.&lt;/P&gt;
&lt;P&gt;You could read the XML from the XLSX file and get the names and the order from that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let filename='c:\downloads\order.xlsx';
%let sheets=sheet_names;

*----------------------------------------------------------------------;
* Generate XMLMAP to read the sheetnames from xl/workbook.xml ;
*----------------------------------------------------------------------;
filename _wbmap temp;
data _null_;
  file _wbmap;
  put '&amp;lt;SXLEMAP version="2.1"&amp;gt;&amp;lt;TABLE name="Sheets"&amp;gt;'
    / '&amp;lt;TABLE-PATH&amp;gt;/workbook/sheets/sheet&amp;lt;/TABLE-PATH&amp;gt;'
    / '&amp;lt;COLUMN name="Sheet"&amp;gt;&amp;lt;TYPE&amp;gt;character&amp;lt;/TYPE&amp;gt;'
    / '&amp;lt;DESCRIPTION&amp;gt;Sheet Name&amp;lt;/DESCRIPTION&amp;gt;'
    / '&amp;lt;PATH&amp;gt;/workbook/sheets/sheet/@name&amp;lt;/PATH&amp;gt;'
    / '&amp;lt;DATATYPE&amp;gt;string&amp;lt;/DATATYPE&amp;gt;&amp;lt;LENGTH&amp;gt;32&amp;lt;/LENGTH&amp;gt;'
    / '&amp;lt;/COLUMN&amp;gt;'
    / '&amp;lt;COLUMN name="State"&amp;gt;&amp;lt;TYPE&amp;gt;character&amp;lt;/TYPE&amp;gt;'
    / '&amp;lt;DESCRIPTION&amp;gt;Sheet State&amp;lt;/DESCRIPTION&amp;gt;'
    / '&amp;lt;PATH&amp;gt;/workbook/sheets/sheet/@state&amp;lt;/PATH&amp;gt;'
    / '&amp;lt;DATATYPE&amp;gt;string&amp;lt;/DATATYPE&amp;gt;&amp;lt;LENGTH&amp;gt;20&amp;lt;/LENGTH&amp;gt;'
    / '&amp;lt;/COLUMN&amp;gt;'
    / '&amp;lt;/TABLE&amp;gt;&amp;lt;/SXLEMAP&amp;gt;'
  ;
run;

*----------------------------------------------------------------------;
* Generate LIBNAME pointing to xl/workbook.xml inside the XLSX file ;
%* Note: Cannot use ZIP filename engine with XMLV2 libname engine ;
*----------------------------------------------------------------------;
filename _wb temp;
data _null_ ;
  infile &amp;amp;filename zip member='xl/workbook.xml';
  file _wb;
  input;
  put _infile_;
run;
libname _wb xmlv2 xmlmap=_wbmap ;

*----------------------------------------------------------------------;
* Read sheet names from XLSX file into a SAS dataset. ;
* Create valid SAS dataset name from sheetname or sheetnumber. ;
*----------------------------------------------------------------------;
data &amp;amp;sheets ;
  if eof then call symputx('nsheets',_n_-1);
  length Number 8;
  set _wb.sheets end=eof;
  number+1;
  length Memname $32 Filename $256 ;
  label number='Sheet Number' memname='Mapped SAS Memname' filename='Source Filename' ;
  filename = &amp;amp;filename ;
  if ^nvalid(compress(sheet),'v7') then memname = cats('Sheet',number);
  else memname = translate(trim(compbl(sheet)),'_',' ');
run;

*----------------------------------------------------------------------;
* Clear the libname and filenames used in reading the sheetnames. ;
*----------------------------------------------------------------------;
libname _wb clear ;
filename _wb clear ;
filename _wbmap clear ;

proc print data=&amp;amp;sheets;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Result for example where I renamed Sheet2 to Was2 and moved it before Sheet1.&lt;/P&gt;
&lt;PRE&gt;Obs    Number    Sheet     State    Memname           Filename

 1        1      Was2               Was2       c:\downloads\order.xlsx
 2        2      Sheet1             Sheet1     c:\downloads\order.xlsx
 3        3      Sheet3             Sheet3     c:\downloads\order.xlsx
&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jul 2020 19:19:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669273#M200749</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-14T19:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669378#M200798</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278672"&gt;@ketpt42&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;With your libname connection, you should be able to find the 2nd sheet name using the sashelp.vtable dictionary view.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;SASHELP.VTABLE (and DICTIONARY.TABLES) does not contain a sequence number for the physical order of datasets in a library, you always get the datasets ordered alphabetically (collating order of your locale).&lt;/P&gt;
&lt;P&gt;Extracting the order out of the XML (as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;suggested) seems to be the only way to do what the OP wants.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 07:46:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669378#M200798</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-15T07:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669432#M200819</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; already mentioned that in his reply.</description>
      <pubDate>Wed, 15 Jul 2020 12:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/669432#M200819</guid>
      <dc:creator>ketpt42</dc:creator>
      <dc:date>2020-07-15T12:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694511#M211818</link>
      <description>&lt;P&gt;its not working out for .xls files&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 11:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694511#M211818</guid>
      <dc:creator>Padma_stat</dc:creator>
      <dc:date>2020-10-27T11:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694519#M211820</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/337725"&gt;@Padma_stat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;its not working out for .xls files&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Of course not. An XLS file uses a totally different format than an XLSX file.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 12:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694519#M211820</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-27T12:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694524#M211822</link>
      <description>&lt;P&gt;which option i need to change for reading .xls files&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 12:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694524#M211822</guid>
      <dc:creator>Padma_stat</dc:creator>
      <dc:date>2020-10-27T12:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694531#M211824</link>
      <description>&lt;P&gt;Don't start new questions on old threads. Open a new question and describe what your issue is with your XLS file.&amp;nbsp; (Is there anyway you could just convert the XLS file to an XLSX file, for example by using Excel to open and save as?)&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 12:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694531#M211824</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-27T12:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to import second sheet from Excel workbook in to SAS without mentioning Sheet name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694556#M211832</link>
      <description>&lt;P&gt;By all means, save your file in XLSX format and use that. The XLSX engine works on all SAS platforms and does not suffer from any bitness issues.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 12:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-second-sheet-from-Excel-workbook-in-to-SAS-without/m-p/694556#M211832</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-27T12:51:57Z</dc:date>
    </item>
  </channel>
</rss>

