<?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: proc sql and connect using in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956100#M373360</link>
    <description>&lt;P&gt;When I do this, I specify a DATASRC argument:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
connect to SQLSVR as Q (datasrc=DBNAME);&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;*... where DBNAME is the name of your target database, as in [DBNAME].[schema].[tablename] ;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Jan 2025 18:40:33 GMT</pubDate>
    <dc:creator>quickbluefish</dc:creator>
    <dc:date>2025-01-14T18:40:33Z</dc:date>
    <item>
      <title>proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956061#M373347</link>
      <description>&lt;P&gt;We have a sas grid environment with predefined libraries (against sql server).&amp;nbsp; This works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
create table work.test as select * from quest.BusinessUnit;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, this fails:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
connect using quest as q;
create table work.test as
select * from connection to q (
	select * from businessunit
);
disconnect from q;
quit;&lt;/PRE&gt;
&lt;P&gt;with this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;39 connect using quest as q;&lt;BR /&gt;ERROR: CLI error trying to establish connection: [DataDirect][ODBC lib] Data source name not found and no default driver specified&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 14:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956061#M373347</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2025-01-14T14:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956099#M373359</link>
      <description>&lt;P&gt;Do you have a Putty terminal or similar where you can access the SAS Grid server?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 18:36:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956099#M373359</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-14T18:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956100#M373360</link>
      <description>&lt;P&gt;When I do this, I specify a DATASRC argument:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
connect to SQLSVR as Q (datasrc=DBNAME);&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;*... where DBNAME is the name of your target database, as in [DBNAME].[schema].[tablename] ;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jan 2025 18:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956100#M373360</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-14T18:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956101#M373361</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223320"&gt;@quickbluefish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;When I do this, I specify a DATASRC argument:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
connect to SQLSVR as Q (datasrc=DBNAME);&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;*... where DBNAME is the name of your target database, as in [DBNAME].[schema].[tablename] ;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;CONNECT TO and CONNECT USING are two different statements with different meaning and syntax.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 18:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956101#M373361</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-14T18:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956104#M373362</link>
      <description>&lt;P&gt;I do.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 18:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956104#M373362</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2025-01-14T18:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956105#M373363</link>
      <description>In the terminal, type 'klist' and tell us what you see.</description>
      <pubDate>Tue, 14 Jan 2025 19:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956105#M373363</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-14T19:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956106#M373364</link>
      <description>...well, don't tell us exactly what you see, but just make sure it doesn't say something to the effect of, "no credentials found".  I find that this is the source of my problems sometimes when I get the error you describe.  Happens when something goes wrong with authentication at login.</description>
      <pubDate>Tue, 14 Jan 2025 19:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956106#M373364</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-14T19:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956107#M373365</link>
      <description>&lt;P&gt;So in our environment, the username/passwords are stored in an authdomain and are used in the predefined library.&amp;nbsp; If I try and use just the datasource name, I get this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql noprint;&lt;BR /&gt;35 connect to sqlsvr as q (datasrc=QUEST);&lt;BR /&gt;ERROR: CLI error trying to establish connection: [SAS][ODBC SQL Server Wire Protocol driver][SQL Server]Login failed for user ''.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 19:06:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956107#M373365</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2025-01-14T19:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956113#M373367</link>
      <description>&lt;P&gt;I see&amp;nbsp;&lt;/P&gt;
&lt;P&gt;credentials cache 'XXXXX' not found&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 19:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956113#M373367</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2025-01-14T19:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956114#M373368</link>
      <description>&lt;P&gt;I suggest you test CONNECT USING with a LIBNAME statement first. I've tried CONNECT USING with a metadata-defined database connection and I've not been able to get it working. I'm not sure what the problem is. It might be use of the DEFER = YES LIBNAME option for greater efficiency.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 19:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956114#M373368</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-01-14T19:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956115#M373369</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;- yeah, I'm not familiar with the 'connect using' syntax.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 19:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956115#M373369</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-14T19:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956117#M373370</link>
      <description>&lt;P&gt;I'm not sure if it's the same syntax, but our corresponding libname is written like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
libname Q sqlsvr datasrc=DBNAME schema=SCHEMA;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure if specifying schema is necessary.&amp;nbsp; If so, it might be something like schema=Dflt&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 19:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956117#M373370</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-14T19:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956118#M373371</link>
      <description>&lt;P&gt;we do use "connect using" for other predefined libraries...but they're oracle and not sqlserver.&amp;nbsp; just trying to troubleshoot a bit&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 19:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956118#M373371</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2025-01-14T19:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956122#M373372</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13871"&gt;@DBailey&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;we do use "connect using" for other predefined libraries...but they're oracle and not sqlserver.&amp;nbsp; just trying to troubleshoot a bit&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did you try exercising the libref using some other command, like PROC CONTENTS to make sure it is working, before trying to run the CONNECT USING ?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 20:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956122#M373372</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-14T20:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956123#M373373</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13871"&gt;@DBailey&lt;/a&gt;&amp;nbsp;- My issue is with SQL Server and SAS/Access Interface to ODBC. CONNECT USING works fine with a prior LIBNAME statement, but not with a pre-defined library.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 20:02:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956123#M373373</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-01-14T20:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956130#M373374</link>
      <description>&lt;P&gt;I just tried that:&lt;/P&gt;
&lt;DIV&gt;proc sql;&lt;/DIV&gt;
&lt;DIV&gt;select count(*) as recs&lt;/DIV&gt;
&lt;DIV&gt;from quest.businessunit;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;connect using quest as q;&lt;/DIV&gt;
&lt;DIV&gt;create table work.test as select * from connection to q (&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; select * from businessunit&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; );&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;disconnect from q;&lt;/DIV&gt;
&lt;DIV&gt;quit;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the count worked but the connect using did not.&lt;/P&gt;
&lt;P&gt;ODBC_2: Prepared: on connection 1&lt;BR /&gt;select COUNT(*) as "recs" from "dbo"."businessunit" TXT_1 WITH (NOLOCK)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ODBC_3: Executed: on connection 1&lt;BR /&gt;Prepared statement ODBC_2&lt;BR /&gt;&lt;BR /&gt;ACCESS ENGINE: SQL statement was passed to the DBMS for fetching data. &lt;BR /&gt;37 &lt;BR /&gt;38 connect using quest as q;&lt;BR /&gt;ERROR: CLI error trying to establish connection: [DataDirect][ODBC lib] Data source name not found and no default driver specified&lt;BR /&gt;&lt;BR /&gt;I'll see if I can find the authdomain and try a "connect to" instead of "connect as"&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 20:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956130#M373374</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2025-01-14T20:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956131#M373375</link>
      <description>&lt;P&gt;specifying a schema is required if you need something other than the default and if you want to browse the library contents.&amp;nbsp; I think the most often used default is dbo&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and i'm going to try and get the auth domain so I can execute the libname statement directly.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 20:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956131#M373375</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2025-01-14T20:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql and connect using</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956132#M373376</link>
      <description>&lt;P&gt;In that case open a ticket with SAS support and see if they can explain why it does not work and whether there is a solution.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 20:31:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-and-connect-using/m-p/956132#M373376</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-14T20:31:30Z</dc:date>
    </item>
  </channel>
</rss>

