<?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: Check if ODBC connection is created or not in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271527#M54022</link>
    <description>&lt;P&gt;An ODBC connection in SAS SQL only lasts as long as the SQL step boundary (the QUIT statement or another DATA or PROC statement) then it is automatically disconnected. Why do you want to check your connection? If it doesn't work then you get appropriate messages in your SAS log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql
  connect to ODBC as mydb (....); &amp;lt;== creates connection

  SQL statements

quit; &amp;lt;== removes connection&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 May 2016 19:54:31 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2016-05-18T19:54:31Z</dc:date>
    <item>
      <title>Check if ODBC connection is created or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271461#M54001</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created ODBC connection from&amp;nbsp;&lt;SPAN class="xis-selection"&gt;Start&lt;IMG src="http://support.sas.com/documentation/cdl/en/bidsag/68193/HTML/default/images/arrow.gif" border="0" alt="then select" width="11" height="10" /&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-selection"&gt;Control Panel&amp;nbsp;&lt;IMG src="http://support.sas.com/documentation/cdl/en/bidsag/68193/HTML/default/images/arrow.gif" border="0" alt="then select" width="11" height="10" /&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-selection"&gt;System and Security&lt;/SPAN&gt;&lt;SPAN class="xis-selectionArrow"&gt;&lt;IMG src="http://support.sas.com/documentation/cdl/en/bidsag/68193/HTML/default/images/arrow.gif" border="0" alt="then select" width="11" height="10" /&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-selection"&gt;Administrative Tools&lt;/SPAN&gt;&lt;SPAN class="xis-selectionArrow"&gt;&lt;IMG src="http://support.sas.com/documentation/cdl/en/bidsag/68193/HTML/default/images/arrow.gif" border="0" alt="then select" width="11" height="10" /&gt;&lt;/SPAN&gt;&lt;SPAN class="xis-selection"&gt;Data Sources (ODBC).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="xis-selection"&gt;In SAS code i created the connection as follow:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;connect to odbc as mydb (dsn=&amp;amp;dsn);&lt;/P&gt;&lt;P&gt;execute&lt;BR /&gt;(set nocount on) by mydb;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need to check if mydb object is actually connected to DB or not. so please help me to implement this in SAS&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i think it will be like that:&amp;nbsp;&lt;/P&gt;&lt;P&gt;if not mydb then &amp;nbsp;-- if the connection isn't created, then create the connection&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; connect to odbc as mydb (dsn=&amp;amp;dsn);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; execute&lt;BR /&gt;&amp;nbsp; &amp;nbsp; (set nocount on) by mydb;&lt;/P&gt;&lt;P&gt;endif&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 16:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271461#M54001</guid>
      <dc:creator>shymaa</dc:creator>
      <dc:date>2016-05-18T16:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Check if ODBC connection is created or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271527#M54022</link>
      <description>&lt;P&gt;An ODBC connection in SAS SQL only lasts as long as the SQL step boundary (the QUIT statement or another DATA or PROC statement) then it is automatically disconnected. Why do you want to check your connection? If it doesn't work then you get appropriate messages in your SAS log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql
  connect to ODBC as mydb (....); &amp;lt;== creates connection

  SQL statements

quit; &amp;lt;== removes connection&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 19:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271527#M54022</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-05-18T19:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Check if ODBC connection is created or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271552#M54024</link>
      <description>&lt;P&gt;You should be able to assign a library to the odbc connection and then use any of the SAS tools for examining the contents of the library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;P&gt;libname test odbc noprompt="dsn=&amp;amp;dsn";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the library gets assigned you should see data there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 22:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271552#M54024</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-18T22:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Check if ODBC connection is created or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271569#M54028</link>
      <description>&lt;P&gt;Check function&amp;nbsp;libname() or&amp;nbsp;libref() &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if (%sysfunc(libref(sashelp))) %then %put ERROR ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 May 2016 01:36:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271569#M54028</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-19T01:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Check if ODBC connection is created or not</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271644#M54040</link>
      <description>&lt;P&gt;Hi SASkiwi&lt;SPAN class="login-bold"&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Thanks for your help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;yes, i found that sometimes the connection isn't created and the below line write in CSV file which contains the statistical result.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;Line:&amp;nbsp;connect to odbc as mydb (dsn=&amp;amp;dsn)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;so i need to put the connection in for loop and it will end once the connection is created something like that&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;do i=1 to 5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if&amp;nbsp;connect to odbc as mydb (dsn=&amp;amp;dsn) then &amp;nbsp;--&amp;gt; if the connection created&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i++;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;End;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="login-bold"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2016 08:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-ODBC-connection-is-created-or-not/m-p/271644#M54040</guid>
      <dc:creator>shymaa</dc:creator>
      <dc:date>2016-05-19T08:43:37Z</dc:date>
    </item>
  </channel>
</rss>

