<?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: Multiple excel sheets and get all headers from each excel file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872609#M344739</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381519"&gt;@Emma2021&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll use portion of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myfile xlsx 'myfile.xlsx';&lt;BR /&gt;proc contents data=myfile._all_ out=contents noprint; &lt;BR /&gt;run;&lt;BR /&gt;libname myfile clear;&lt;BR /&gt;&lt;BR /&gt;/* Extract the "DATA" sheet column headers */&lt;BR /&gt;DATA want(keep=name);&lt;BR /&gt;   set contents(keep=name memname where=(memname='DATA'));&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Apr 2023 16:51:42 GMT</pubDate>
    <dc:creator>AhmedAl_Attar</dc:creator>
    <dc:date>2023-04-27T16:51:42Z</dc:date>
    <item>
      <title>Multiple excel sheets and get all headers from each excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872423#M344686</link>
      <description>I have multiple excel files with multiple sheets. From each excel file, if sheet name is as “data” then I would like to get all column headings’ names. How can I do that in SAS. Thank you.</description>
      <pubDate>Thu, 27 Apr 2023 02:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872423#M344686</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2023-04-27T02:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple excel sheets and get all headers from each excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872590#M344731</link>
      <description>&lt;P&gt;Figure it out for one and then figure out how to scale it. &lt;BR /&gt;&lt;BR /&gt;If you assign a libname to the Excel file and then check the data tab does it have the column headers?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myxl 'path to xlsx file';

proc contents data=myxl.data;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 16:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872590#M344731</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-04-27T16:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple excel sheets and get all headers from each excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872592#M344732</link>
      <description>Sorry, can you write the complete code? I have to use sheet name as “data” since there can be multiple sheets. Thank you.</description>
      <pubDate>Thu, 27 Apr 2023 15:38:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872592#M344732</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2023-04-27T15:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple excel sheets and get all headers from each excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872596#M344735</link>
      <description>&lt;P&gt;You can just use the XLSX engine to treat the workbook as a library of datasets.&lt;/P&gt;
&lt;P&gt;The NAME of the variables will be derived from the headers in the first row of each sheet.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myfile xlsx 'myfile.xlsx';
proc contents data=myfile._all_ out=contents noprint; run;
proc print data=contents;
  by memname;
  id memname;
  var varnum name label ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 15:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872596#M344735</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-27T15:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple excel sheets and get all headers from each excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872609#M344739</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/381519"&gt;@Emma2021&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'll use portion of&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myfile xlsx 'myfile.xlsx';&lt;BR /&gt;proc contents data=myfile._all_ out=contents noprint; &lt;BR /&gt;run;&lt;BR /&gt;libname myfile clear;&lt;BR /&gt;&lt;BR /&gt;/* Extract the "DATA" sheet column headers */&lt;BR /&gt;DATA want(keep=name);&lt;BR /&gt;   set contents(keep=name memname where=(memname='DATA'));&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 16:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872609#M344739</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2023-04-27T16:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple excel sheets and get all headers from each excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872611#M344741</link>
      <description>The excel files are xls or xlsx and also each excel file has multiple sheets —I only need column names for sheet names “data”. How can I do that?</description>
      <pubDate>Thu, 27 Apr 2023 17:03:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872611#M344741</guid>
      <dc:creator>Emma2021</dc:creator>
      <dc:date>2023-04-27T17:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple excel sheets and get all headers from each excel file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872658#M344762</link>
      <description>&lt;P&gt;XLS files are much harder as there is no XLS libname engine to use.&lt;/P&gt;
&lt;PRE&gt;1248  libname xls xls "c:\downloads\test_class.xls" ;
ERROR: The XLS engine cannot be found.
ERROR: Error in the LIBNAME statement.
&lt;/PRE&gt;
&lt;P&gt;If you are running on windows (and you can get it to work) you might be able to use the EXCEL libname engine instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to only see the names of the variables in the datasets that have the string 'DATA' in their name then just subset the CONTENTS data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=contents;
  where memname like '%DATA%' ;
  var memname varnum name;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 19:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-excel-sheets-and-get-all-headers-from-each-excel-file/m-p/872658#M344762</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-27T19:43:12Z</dc:date>
    </item>
  </channel>
</rss>

