<?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: Get first created sheet name of excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708024#M217494</link>
    <description>&lt;P&gt;Do you have&amp;nbsp;&lt;SPAN&gt;'‪C:\Users\pooja\Desktop\Try2.xlsx'?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I tried to submit your code, I got success and error;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If xlsx file is exists and not double byte character in filename , I got success.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If xlsx file is not exists or exists double byte character(I tried Japanese, maybe other than language is same) in filename, I got same error.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you try this code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename foo ZIP 'C:\Users\pooja\Desktop\Try2.xlsx' member='xl/workbook.xml';

data _null_;
infile foo;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If zip access method got success, you get xml contens in log window.&lt;/P&gt;
&lt;P&gt;If you got error "Open failure for XXXXX during attempt to create a local filehandle.", you cannot access your xlsx file.&lt;/P&gt;
&lt;P&gt;Then please try a new excel file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Dec 2020 02:00:08 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2020-12-24T02:00:08Z</dc:date>
    <item>
      <title>Get first created sheet name of excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708020#M217493</link>
      <description>&lt;P&gt;Hi , Plz help with the below scenario&lt;/P&gt;&lt;P&gt;I wan to know the first Sheet name (order of creation) in an excel sheet. Is there any way.&lt;/P&gt;&lt;P&gt;Somebody suggested using XML (i.e consider excel as xml)&lt;/P&gt;&lt;P&gt;Use the below code but getting error:&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;filename src ZIP '‪C:\Users\pooja\Desktop\Try2.xlsx' member='xl/workbook.xml';&lt;BR /&gt;filename des temp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;rc=fcopy('src','des');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;filename srcmap temp;&lt;BR /&gt;libname des xmlv2 xmlmap=srcmap automap=reuse;&lt;/P&gt;&lt;P&gt;data sheet_names;&lt;BR /&gt;set des.sheet;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print width= min;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;libname des xmlv2 xmlmap=srcmap automap=reuse;&lt;BR /&gt;ERROR: With the AUTOMAP= option, the specified XML document must exist.&lt;BR /&gt;ERROR: Error in the LIBNAME statement.&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2020 23:43:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708020#M217493</guid>
      <dc:creator>pooja86kaushal</dc:creator>
      <dc:date>2020-12-23T23:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Get first created sheet name of excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708024#M217494</link>
      <description>&lt;P&gt;Do you have&amp;nbsp;&lt;SPAN&gt;'‪C:\Users\pooja\Desktop\Try2.xlsx'?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I tried to submit your code, I got success and error;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If xlsx file is exists and not double byte character in filename , I got success.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If xlsx file is not exists or exists double byte character(I tried Japanese, maybe other than language is same) in filename, I got same error.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you try this code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename foo ZIP 'C:\Users\pooja\Desktop\Try2.xlsx' member='xl/workbook.xml';

data _null_;
infile foo;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If zip access method got success, you get xml contens in log window.&lt;/P&gt;
&lt;P&gt;If you got error "Open failure for XXXXX during attempt to create a local filehandle.", you cannot access your xlsx file.&lt;/P&gt;
&lt;P&gt;Then please try a new excel file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Dec 2020 02:00:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708024#M217494</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2020-12-24T02:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get first created sheet name of excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708077#M217523</link>
      <description>I also want know how to get it .</description>
      <pubDate>Thu, 24 Dec 2020 13:49:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708077#M217523</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-12-24T13:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get first created sheet name of excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708086#M217525</link>
      <description>&lt;P&gt;Not sure why the FILENAME statement is having trouble.&amp;nbsp; Why not just use the INFILE statement directly?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename des temp;
data _null_;
  infile '‪C:\Users\pooja\Desktop\Try2.xlsx' zip member='xl/workbook.xml' recfm=n;
  file des recfm=n;
  input;
  put _infile_;
run;
filename srcmap temp;
libname des xmlv2 xmlmap=srcmap automap=reuse;

data sheet_names;
set des.sheet;
run;

proc print width= min;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Dec 2020 14:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708086#M217525</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-24T14:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get first created sheet name of excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708182#M217576</link>
      <description>Tom,&lt;BR /&gt;whether there is another way to get it or not? i.e. My sas is 9.2 or 9.3</description>
      <pubDate>Fri, 25 Dec 2020 11:38:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708182#M217576</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-12-25T11:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Get first created sheet name of excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708189#M217581</link>
      <description>&lt;P&gt;Maybe the following code is ugly and not right solution. But could give it a try .&lt;/P&gt;
&lt;P&gt;I just compare the variable name in the FIRST sheet. If same ,then take it as the first sheet name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any validmemname=extend;

proc import datafile='c:\temp\temp.xlsx' out=_temp_ dbms=xlsx replace;
getnames=yes;
run;

libname x excel 'c:\temp\temp.xlsx';
proc copy in=x out=work;
run;

proc sql noprint;
select quote(name) into : list separated by ' '
 from dictionary.columns
  where libname='WORK' and memname='_TEMP_';

select count(*) into : n
 from dictionary.columns
  where libname='WORK' and memname='_TEMP_';

create table want as
select *
 from dictionary.columns
  where libname='WORK' and memname ne '_TEMP_'
   group by memname 
    having &amp;amp;n.=sum(name in (&amp;amp;list.));

quit;

title 'First Sheet Name:';
proc sql;
select distinct memname from want;
quit;

libname x clear;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Dec 2020 14:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708189#M217581</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-12-25T14:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get first created sheet name of excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708197#M217585</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Tom,&lt;BR /&gt;whether there is another way to get it or not? i.e. My sas is 9.2 or 9.3&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you are using an old version of SAS that does not support the ZIP libname engine then use your local operating system command for extracting files from a ZIP file to get the XML file with the list of sheets.&amp;nbsp; If your old version of SAS does not support reading XML then just parse the text of the file yourself with a data step.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2020 16:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-first-created-sheet-name-of-excel/m-p/708197#M217585</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-25T16:53:27Z</dc:date>
    </item>
  </channel>
</rss>

