<?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 Pass-Through SQL returns different results than equivalent data step or proc sql using libname? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286165#M58651</link>
    <description>&lt;P&gt;I'm hoping someone here knows what's going on...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just upgraded to SAS 9.4. &amp;nbsp;I have one data step and two proc SQL procs that I &lt;EM&gt;think&lt;/EM&gt; should be returning the same result set from SQL Server:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname diablo   odbc DATABASE=DEV_Diablo               
                      schema=tTrans;
proc sql;

create table test as

select t.*

FROM Diablo.Trans         t

where t.CntyCd      = '51059'
;

quit;
proc sql;

connect to odbc (dsn="DEV_Diablo");

create table test1 as
select * from connection to odbc
(
SELECT *
  FROM [Diablo].[tTrans].[Trans]
  where CntyCd = '51059'
)
;
disconnect from odbc;
quit;
data test2;
  set diablo.Trans;

where CntyCd = '51059';

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;[Diablo].[tTrans].[Trans] is a honking big table, and CntyCd 51059 is my home county of Fairfax in Virginia - it's pretty populous. &amp;nbsp;I would expect at least one million rows to return (population = 1.1 million). &amp;nbsp;But here's what I get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    libname diablo   odbc DATABASE=DEV_Diablo
2                          schema=tTrans;
NOTE: Libref DIABLO was successfully assigned as follows:
      Engine:        ODBC
      Physical Name: DEV_Diablo
3    proc sql;
4
5    create table test as
6
7    select t.*
8
9    FROM Diablo.Trans         t
10
11   where t.CntyCd      = '51059'
12   ;
NOTE: Table WORK.TEST created, with 415 rows and 395 columns.

13
14   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.62 seconds
      cpu time            0.21 seconds

29   proc sql;
30
31   connect to odbc (dsn="DEV_Diablo");
32
33   create table test1 as
34   select * from connection to odbc
35   (
36   SELECT *
37     FROM [Diablo].[tTrans].[Trans]
38     where CntyCd = '51059'
39   )
40   ;
NOTE: Table WORK.TEST1 created, with 3420645 rows and 395 columns.

41   disconnect from odbc;
42   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           19:44.13
      cpu time            4:55.51

49   data test2;
50     set diablo.Trans;
51
52   where CntyCd = '51059';
53
54   run;

NOTE: There were 415 observations read from the data set DIABLO.Trans.
      WHERE CntyCd='51059';
NOTE: The data set WORK.TEST2 has 415 observations and 395 variables.
NOTE: DATA statement used (Total process time):
      real time           0.40 seconds
      cpu time            0.04 seconds

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The results from the pass-through SQL are what I would expect from the other two methods, as well. &amp;nbsp;I'll be using pass-through on this project, but the fact that the other two methods don't return the same result set is making me nervous. &amp;nbsp;Is this a bug?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Jul 2016 15:30:00 GMT</pubDate>
    <dc:creator>Malarkey</dc:creator>
    <dc:date>2016-07-21T15:30:00Z</dc:date>
    <item>
      <title>Pass-Through SQL returns different results than equivalent data step or proc sql using libname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286165#M58651</link>
      <description>&lt;P&gt;I'm hoping someone here knows what's going on...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just upgraded to SAS 9.4. &amp;nbsp;I have one data step and two proc SQL procs that I &lt;EM&gt;think&lt;/EM&gt; should be returning the same result set from SQL Server:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname diablo   odbc DATABASE=DEV_Diablo               
                      schema=tTrans;
proc sql;

create table test as

select t.*

FROM Diablo.Trans         t

where t.CntyCd      = '51059'
;

quit;
proc sql;

connect to odbc (dsn="DEV_Diablo");

create table test1 as
select * from connection to odbc
(
SELECT *
  FROM [Diablo].[tTrans].[Trans]
  where CntyCd = '51059'
)
;
disconnect from odbc;
quit;
data test2;
  set diablo.Trans;

where CntyCd = '51059';

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;[Diablo].[tTrans].[Trans] is a honking big table, and CntyCd 51059 is my home county of Fairfax in Virginia - it's pretty populous. &amp;nbsp;I would expect at least one million rows to return (population = 1.1 million). &amp;nbsp;But here's what I get:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    libname diablo   odbc DATABASE=DEV_Diablo
2                          schema=tTrans;
NOTE: Libref DIABLO was successfully assigned as follows:
      Engine:        ODBC
      Physical Name: DEV_Diablo
3    proc sql;
4
5    create table test as
6
7    select t.*
8
9    FROM Diablo.Trans         t
10
11   where t.CntyCd      = '51059'
12   ;
NOTE: Table WORK.TEST created, with 415 rows and 395 columns.

13
14   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.62 seconds
      cpu time            0.21 seconds

29   proc sql;
30
31   connect to odbc (dsn="DEV_Diablo");
32
33   create table test1 as
34   select * from connection to odbc
35   (
36   SELECT *
37     FROM [Diablo].[tTrans].[Trans]
38     where CntyCd = '51059'
39   )
40   ;
NOTE: Table WORK.TEST1 created, with 3420645 rows and 395 columns.

41   disconnect from odbc;
42   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           19:44.13
      cpu time            4:55.51

49   data test2;
50     set diablo.Trans;
51
52   where CntyCd = '51059';
53
54   run;

NOTE: There were 415 observations read from the data set DIABLO.Trans.
      WHERE CntyCd='51059';
NOTE: The data set WORK.TEST2 has 415 observations and 395 variables.
NOTE: DATA statement used (Total process time):
      real time           0.40 seconds
      cpu time            0.04 seconds

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The results from the pass-through SQL are what I would expect from the other two methods, as well. &amp;nbsp;I'll be using pass-through on this project, but the fact that the other two methods don't return the same result set is making me nervous. &amp;nbsp;Is this a bug?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 15:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286165#M58651</guid>
      <dc:creator>Malarkey</dc:creator>
      <dc:date>2016-07-21T15:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-Through SQL returns different results than equivalent data step or proc sql using libname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286189#M58659</link>
      <description>&lt;P&gt;You should talk to SAS Support here, they'll help you debug this quickly and if it is a bug they should be notified.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 17:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286189#M58659</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-21T17:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-Through SQL returns different results than equivalent data step or proc sql using libname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286190#M58660</link>
      <description>I will do that, Reeza.  Thanks!</description>
      <pubDate>Thu, 21 Jul 2016 17:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286190#M58660</guid>
      <dc:creator>Malarkey</dc:creator>
      <dc:date>2016-07-21T17:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-Through SQL returns different results than equivalent data step or proc sql using libname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286240#M58671</link>
      <description>&lt;P&gt;Try running your queries with these troubleshooting options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options sastrace = ',,,d' SASTRACELOC = SASLOG;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It will write extra info to your SAS log that might help explain the differences in your queries.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 19:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286240#M58671</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-07-21T19:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-Through SQL returns different results than equivalent data step or proc sql using libname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286306#M58694</link>
      <description>&lt;PRE&gt;

DataBase Product like Oracle DB2 ...  they all treat MISSING and NULL are different value , But SAS is going to treat them the same 
thing. 
Maybe that is the reason why you got different result .

&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2016 01:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/286306#M58694</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-22T01:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-Through SQL returns different results than equivalent data step or proc sql using libname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/287486#M59164</link>
      <description>&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;suggested, I opened a ticket with SAS.&amp;nbsp; They suggested adding the qualifier parameter to my libname statement and that did the trick:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname diablo   odbc DATABASE=DEV_Diablo               
                      schema=tTrans qualifier=Diablo;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jul 2016 14:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/287486#M59164</guid>
      <dc:creator>Malarkey</dc:creator>
      <dc:date>2016-07-27T14:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-Through SQL returns different results than equivalent data step or proc sql using libname?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/287488#M59165</link>
      <description>&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;suggested, I opened a ticket with SAS.&amp;nbsp; They suggested adding the qualifier parameter to my libname statement, and that did the trick:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname diablo   odbc DATABASE=DEV_Diablo               
                      schema=tTrans qualifier=Diablo;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Jul 2016 14:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Through-SQL-returns-different-results-than-equivalent-data/m-p/287488#M59165</guid>
      <dc:creator>Malarkey</dc:creator>
      <dc:date>2016-07-27T14:25:00Z</dc:date>
    </item>
  </channel>
</rss>

