<?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 Connect to ODBC and using join with existing SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396818#M95840</link>
    <description>&lt;P&gt;Good Morning everyone! So, Im trying to connect with SQL server using connect to ODBC and it works well as long as im quering the data from a table in SQL server. But, at times, I need to join the table im quering with a local SAS dataset. I use the following code and it gives me error. Ofcourse there is an option of getting the whole table from sql sever first and then do the join, but the tables im working with are very big tables in sql server and also the data changes in them constantly, so bringing them first to SAS will be a pain.&lt;/P&gt;
&lt;P&gt;In the code below, enbmast is the big table in sql server. The code below works fine if I dont join it with members table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;connect&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; odbc &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; AX (dsn=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"EIM"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test_ &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; *&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; connection to AX (&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a.acctno, SUM(a.trnamt) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; TRNAMT1, b.memID&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; enbmast a join work.members b on a.acctno =b.acctno&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;GROUP&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;BY&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ACCTNO&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;);&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks so much in advance!&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Sep 2017 14:31:20 GMT</pubDate>
    <dc:creator>devsas</dc:creator>
    <dc:date>2017-09-18T14:31:20Z</dc:date>
    <item>
      <title>Connect to ODBC and using join with existing SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396818#M95840</link>
      <description>&lt;P&gt;Good Morning everyone! So, Im trying to connect with SQL server using connect to ODBC and it works well as long as im quering the data from a table in SQL server. But, at times, I need to join the table im quering with a local SAS dataset. I use the following code and it gives me error. Ofcourse there is an option of getting the whole table from sql sever first and then do the join, but the tables im working with are very big tables in sql server and also the data changes in them constantly, so bringing them first to SAS will be a pain.&lt;/P&gt;
&lt;P&gt;In the code below, enbmast is the big table in sql server. The code below works fine if I dont join it with members table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;connect&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; odbc &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; AX (dsn=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"EIM"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test_ &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; *&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; connection to AX (&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a.acctno, SUM(a.trnamt) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; TRNAMT1, b.memID&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; enbmast a join work.members b on a.acctno =b.acctno&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;GROUP&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;BY&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ACCTNO&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;);&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Thanks so much in advance!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 14:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396818#M95840</guid>
      <dc:creator>devsas</dc:creator>
      <dc:date>2017-09-18T14:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to ODBC and using join with existing SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396831#M95845</link>
      <description>&lt;P&gt;You're using Pass-through so you won't be able to join with SAS data sets as all the "action" takes place in the DB. You'll have to declare a Libname using the ODBC engine as here -&amp;gt;&amp;nbsp;&lt;A href="http://support.sas.com/kb/52/777.html" target="_blank"&gt;http://support.sas.com/kb/52/777.html&lt;/A&gt; and use "normal" Proc SQL&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 15:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396831#M95845</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-18T15:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to ODBC and using join with existing SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396847#M95850</link>
      <description>&lt;P&gt;Thanks so much! I used the code in the link you provided replacing relevant names for database and server names. It seems to work, except that i was not sure of what to put for schema and removing that seems to work. But, just want to confirm if schema option is optional?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;libname&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; mydata odbc complete=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"driver=SQL Server;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;database=DHS;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt; server=EIMSQLCLS2X\ODE"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 15:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396847#M95850</guid>
      <dc:creator>devsas</dc:creator>
      <dc:date>2017-09-18T15:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to ODBC and using join with existing SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396852#M95851</link>
      <description>&lt;P&gt;The schema option is optional but I've found that most places need it. If it isn't explicitly set that you're aware of, try setting it to dbo and see what happens.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 15:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396852#M95851</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-18T15:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Connect to ODBC and using join with existing SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396856#M95853</link>
      <description>&lt;P&gt;Strictly speaking it is optional - if you don't specify a schema you'll connect to the default schema.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 15:46:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Connect-to-ODBC-and-using-join-with-existing-SAS-dataset/m-p/396856#M95853</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-09-18T15:46:21Z</dc:date>
    </item>
  </channel>
</rss>

