<?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: queries have different results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/queries-have-different-results/m-p/834024#M329731</link>
    <description>&lt;P&gt;Can you create sample data that allow to replicate what you tell us? I didn't manage to do it in below code - but may-be you see something in your real data that allows to create data for a case in tables t1 or t2 that I missed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t1;
  input Identity;
  datalines;
1
1
2
2
1
1
;

data t2;
  input Identity routing $;
  datalines;
1 AA
1 XX
2 XX
2 XX
1 BUREAU
1 BUREAU
1 BUREAU
1 AA
1 XX
;

proc sql _method _tree;
  create table A1 as
    select distinct a.Identity,b.routing
      from (select distinct Identity  from t1 ) as a
        left join (Select Identity,routing  from t2) as b
          on a.Identity=b.Identity
        WHERE B.ROUTING NE 'BUREAU'
  ;
quit;

proc sql _method _tree;
  create table A2(WHERE=(ROUTING NE 'BUREAU')) as
    select distinct a.Identity,b.routing
      from (select distinct Identity  from t1) as a
        left join (Select Identity,routing  from t2 ) as b
          on a.Identity=b.Identity
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 18 Sep 2022 10:53:56 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2022-09-18T10:53:56Z</dc:date>
    <item>
      <title>queries have different results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/queries-have-different-results/m-p/834008#M329730</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following 2 queries have different results (number of rows).&lt;/P&gt;
&lt;P&gt;Why?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table A1 as
select distinct a.Identity,b.routing
from (select distinct Identity  from t1 ) as a
left join (Select Identity,routing  from t2) as b
on a.Identity=b.Identity
WHERE b.routing ne 'BUREAU'
;
quit;


proc sql;
create table A2(Where=(routing ne 'BUREAU')) as
select distinct a.Identity,b.routing
from (select distinct Identity  from t1) as a
left join (Select Identity,routing  from t2 ) as b
on a.Identity=b.Identity
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Sep 2022 05:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/queries-have-different-results/m-p/834008#M329730</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-09-18T05:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: queries have different results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/queries-have-different-results/m-p/834024#M329731</link>
      <description>&lt;P&gt;Can you create sample data that allow to replicate what you tell us? I didn't manage to do it in below code - but may-be you see something in your real data that allows to create data for a case in tables t1 or t2 that I missed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t1;
  input Identity;
  datalines;
1
1
2
2
1
1
;

data t2;
  input Identity routing $;
  datalines;
1 AA
1 XX
2 XX
2 XX
1 BUREAU
1 BUREAU
1 BUREAU
1 AA
1 XX
;

proc sql _method _tree;
  create table A1 as
    select distinct a.Identity,b.routing
      from (select distinct Identity  from t1 ) as a
        left join (Select Identity,routing  from t2) as b
          on a.Identity=b.Identity
        WHERE B.ROUTING NE 'BUREAU'
  ;
quit;

proc sql _method _tree;
  create table A2(WHERE=(ROUTING NE 'BUREAU')) as
    select distinct a.Identity,b.routing
      from (select distinct Identity  from t1) as a
        left join (Select Identity,routing  from t2 ) as b
          on a.Identity=b.Identity
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 18 Sep 2022 10:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/queries-have-different-results/m-p/834024#M329731</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-09-18T10:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: queries have different results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/queries-have-different-results/m-p/834027#M329734</link>
      <description>&lt;P&gt;Are your source datasets coming from an external database (such as Oracle, MySQL etc.)?&lt;/P&gt;
&lt;P&gt;Those systems implement TRI level logic whereas SAS only implements BINARY logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In SAS the test (routing ne 'BUREAU') can only be TRUE or FALSE.&amp;nbsp; But if that test was pushed into an external database it could return neither TRUE nor FALSE if the value of ROUTING is null (what they call missing in most database systems).&amp;nbsp; In which case you might need to test (routing ne 'BUREAU' or routing is null).&lt;/P&gt;</description>
      <pubDate>Sun, 18 Sep 2022 15:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/queries-have-different-results/m-p/834027#M329734</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-18T15:36:09Z</dc:date>
    </item>
  </channel>
</rss>

