<?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 Excel ODBC - where the sheet name is unknown in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Excel-ODBC-where-the-sheet-name-is-unknown/m-p/254960#M48668</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I'm using SAS9.3 on a PC with Windows7 / Office 2010.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When using the ODBC Microsoft Excel Drivers to import data from an Excel worksheet into SAS I have encountered a slight problem.&amp;nbsp;&amp;nbsp;&amp;nbsp;Using a macro to loop around and import a number of worksheets the code below can cope with varying columns, but it errors when the sheet name differs from the name specified in my SAS syntax.&lt;/P&gt;
&lt;P&gt;There are too many files to verify manually.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, is there a way to make the statement below more flexible?&amp;nbsp; For example, code it to always take the first worksheet?&lt;/P&gt;
&lt;P&gt;Thanks in advance, Rb1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; connect to odbc (COMPLETE=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"DSN=Excel Files;DBQ=&amp;amp;directory.\&amp;amp;filename..xlsx"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; create table Imported_&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;as select&lt;/P&gt;
&lt;P&gt;*&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; , &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;filename."&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; as Origin&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;from connection to odbc&lt;/P&gt;
&lt;P&gt;(select *&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; from [&lt;STRONG&gt;sheet&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;STRONG&gt;$&lt;/STRONG&gt;])&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;/* Issue - some sheets being imported have been renamed */&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;disconnect from odbc;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2016 15:00:22 GMT</pubDate>
    <dc:creator>RB1Kenobi</dc:creator>
    <dc:date>2016-03-07T15:00:22Z</dc:date>
    <item>
      <title>Excel ODBC - where the sheet name is unknown</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excel-ODBC-where-the-sheet-name-is-unknown/m-p/254960#M48668</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I'm using SAS9.3 on a PC with Windows7 / Office 2010.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When using the ODBC Microsoft Excel Drivers to import data from an Excel worksheet into SAS I have encountered a slight problem.&amp;nbsp;&amp;nbsp;&amp;nbsp;Using a macro to loop around and import a number of worksheets the code below can cope with varying columns, but it errors when the sheet name differs from the name specified in my SAS syntax.&lt;/P&gt;
&lt;P&gt;There are too many files to verify manually.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, is there a way to make the statement below more flexible?&amp;nbsp; For example, code it to always take the first worksheet?&lt;/P&gt;
&lt;P&gt;Thanks in advance, Rb1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; connect to odbc (COMPLETE=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"DSN=Excel Files;DBQ=&amp;amp;directory.\&amp;amp;filename..xlsx"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; create table Imported_&amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;as select&lt;/P&gt;
&lt;P&gt;*&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; , &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;filename."&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; as Origin&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;from connection to odbc&lt;/P&gt;
&lt;P&gt;(select *&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; from [&lt;STRONG&gt;sheet&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;STRONG&gt;$&lt;/STRONG&gt;])&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;/* Issue - some sheets being imported have been renamed */&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;disconnect from odbc;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 15:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excel-ODBC-where-the-sheet-name-is-unknown/m-p/254960#M48668</guid>
      <dc:creator>RB1Kenobi</dc:creator>
      <dc:date>2016-03-07T15:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Excel ODBC - where the sheet name is unknown</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excel-ODBC-where-the-sheet-name-is-unknown/m-p/254978#M48680</link>
      <description>&lt;P&gt;If you would use the Libname Excel (or ODBC) engine instead, you could use SASHELP.VSTABLE/VCLOUMN to drive your&amp;nbsp;logic.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 16:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excel-ODBC-where-the-sheet-name-is-unknown/m-p/254978#M48680</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-03-07T16:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Excel ODBC - where the sheet name is unknown</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Excel-ODBC-where-the-sheet-name-is-unknown/m-p/255029#M48696</link>
      <description>&lt;P&gt;I'm assuming you don't have SAS Access license for the Excel files so your using ODBC as a workaround.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2016 17:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Excel-ODBC-where-the-sheet-name-is-unknown/m-p/255029#M48696</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-07T17:54:21Z</dc:date>
    </item>
  </channel>
</rss>

