<?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 display the sheet  in actual order ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-display-the-sheet-in-actual-order/m-p/747557#M234651</link>
    <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
    <pubDate>Sat, 12 Jun 2021 18:18:54 GMT</pubDate>
    <dc:creator>tianerhu</dc:creator>
    <dc:date>2021-06-12T18:18:54Z</dc:date>
    <item>
      <title>how to display the sheet  in actual order ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-display-the-sheet-in-actual-order/m-p/747536#M234635</link>
      <description>&lt;P&gt;I have a xlsx file , and there are 3 sheet in the xlsx file , the first sheet is SheetA ,the second is SheetBB, the third is SheetC. like this ：&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tianerhu_0-1623501077019.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60301i61BC56AF44174D5D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tianerhu_0-1623501077019.png" alt="tianerhu_0-1623501077019.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname apple  xlsx 'C:\practice everyday\input\input01.xlsx';
proc contents data = apple._all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the output :&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tianerhu_1-1623501175792.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60302i4A994DAB8DE50BF0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tianerhu_1-1623501175792.png" alt="tianerhu_1-1623501175792.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;how to display the sheets in actual order that they are in xlsx file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jun 2021 12:34:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-display-the-sheet-in-actual-order/m-p/747536#M234635</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-06-12T12:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to display the sheet  in actual order ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-display-the-sheet-in-actual-order/m-p/747540#M234636</link>
      <description>&lt;P&gt;If you want to discover the sheet order read the XML file out of the XSLX file (an XLSX file is just a ZIP file) that has that information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let filename='c:\downloads\three.xlsx';
%let sheets=worksheets;

*----------------------------------------------------------------------;
* 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;

*----------------------------------------------------------------------;
* Copy xl/workbook.xml from XLSX file to physical file ;
%* Note: Cannot use ZIP filename engine with XMLV2 libname engine ;
/* filename _wb pipe %sysfunc(quote(unzip -p &amp;amp;filename xl/workbook.xml)); */
*----------------------------------------------------------------------;
filename _wbzip ZIP &amp;amp;filename member='xl/workbook.xml';
filename _wb temp ;
data _null_;
  infile _wbzip recfm=f lrecl=30000;
  file _wb recfm=f lrecl=30000;
  input;
  put _infile_;
run;

*----------------------------------------------------------------------;
* Generate LIBNAME pointing to copy of xl/workbook.xml from XLSX file ;
*----------------------------------------------------------------------;
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 ;
  length Number 8;
  set _wb.sheets end=eof;
  number+1;
  length Memname $51 Filename $256 ;
  label number='Sheet Number' memname='Mapped SAS Memname' filename='Source Filename' ;
  memname = nliteral(sheet) ;
  filename = &amp;amp;filename ;
run;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 325px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60303i75A91991D437867E/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;Obs    Number    Sheet     State    Memname           Filename

 1        1      Sheet2             Sheet2     c:\downloads\three.xlsx
 2        2      Sheet1             Sheet1     c:\downloads\three.xlsx
 3        3      Sheet3             Sheet3     c:\downloads\three.xlsx

&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Jun 2021 15:15:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-display-the-sheet-in-actual-order/m-p/747540#M234636</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-12T15:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to display the sheet  in actual order ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-display-the-sheet-in-actual-order/m-p/747557#M234651</link>
      <description>&lt;P&gt;Thank you for your help.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jun 2021 18:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-display-the-sheet-in-actual-order/m-p/747557#M234651</guid>
      <dc:creator>tianerhu</dc:creator>
      <dc:date>2021-06-12T18:18:54Z</dc:date>
    </item>
  </channel>
</rss>

