<?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: Applying Include Exclude criteria in control data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Applying-Include-Exclude-criteria-in-control-data-set/m-p/838069#M331400</link>
    <description>&lt;P&gt;You are getting the first note because you are not selecting Rownum on the outer Select clause before the nested "except". This is informational because it can indicate that you may expect a result different than you actually get but won't be able to tell why.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second note is because of the join you used:&lt;/P&gt;
&lt;PRE&gt;from names join filter&lt;/PRE&gt;
&lt;P&gt;is a Cartesian join forcing every record in Names to be Joined with every record in Filter.&lt;/P&gt;
&lt;P&gt;If that is not the desired behavior then you use a different join.&lt;/P&gt;
&lt;P&gt;Again this is partially informational in case you did not intend the Cartesian join as they can be very resource intensive. Two data sets of 1000 records each would require 1,000,000 comparisons for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Oct 2022 14:41:20 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-10-12T14:41:20Z</dc:date>
    <item>
      <title>Applying Include Exclude criteria in control data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-Include-Exclude-criteria-in-control-data-set/m-p/838023#M331374</link>
      <description>&lt;P&gt;Consider the problem of applying include and then exclude criteria that are SQL where patterns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am coding a query with an EXCEPT operator that is logging&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.&lt;BR /&gt;NOTE: The execution of this query involves performing one or more Cartesian product joins that can not be optimized.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can the same result be obtained without the notes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data filter;
length state $1 pattern $20;
input state pattern;
datalines;
+ %a%
+ J%
- W%
- %c%
- %y
;

data names;
  set 
    sashelp.class(where=(name &amp;gt;='L'))
    sashelp.class(where=(name &amp;lt; 'L'))
  ;
  rownum + 1;
  keep name rownum;
run;

proc sql;
  create table eval as
  select name from
  ( 
      select name, rownum from names join filter on name like trim(pattern) where state = '+'
      except
      select name, rownum from names join filter on name like trim(pattern) where state = '-'
  )  
  order rownum
;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RichardADeVenezia_0-1665575872380.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76109i42F77E010A94D529/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RichardADeVenezia_0-1665575872380.png" alt="RichardADeVenezia_0-1665575872380.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 11:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-Include-Exclude-criteria-in-control-data-set/m-p/838023#M331374</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2022-10-12T11:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Include Exclude criteria in control data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-Include-Exclude-criteria-in-control-data-set/m-p/838043#M331386</link>
      <description>&lt;P&gt;I am only aware of one way to do this using options nonotes before the proc sql step and then turning the notes back on after the quit statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options &lt;STRONG&gt;nonotes;&lt;/STRONG&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table eval as&lt;BR /&gt;select name from&lt;BR /&gt;( &lt;BR /&gt;select name, rownum from names join filter on name like trim(pattern) where state = '+'&lt;BR /&gt;except&lt;BR /&gt;select name, rownum from names join filter on name like trim(pattern) where state = '-'&lt;BR /&gt;) &lt;BR /&gt;order rownum&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;BR /&gt;options &lt;STRONG&gt;notes;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 13:11:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-Include-Exclude-criteria-in-control-data-set/m-p/838043#M331386</guid>
      <dc:creator>KevinScott</dc:creator>
      <dc:date>2022-10-12T13:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Applying Include Exclude criteria in control data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-Include-Exclude-criteria-in-control-data-set/m-p/838069#M331400</link>
      <description>&lt;P&gt;You are getting the first note because you are not selecting Rownum on the outer Select clause before the nested "except". This is informational because it can indicate that you may expect a result different than you actually get but won't be able to tell why.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second note is because of the join you used:&lt;/P&gt;
&lt;PRE&gt;from names join filter&lt;/PRE&gt;
&lt;P&gt;is a Cartesian join forcing every record in Names to be Joined with every record in Filter.&lt;/P&gt;
&lt;P&gt;If that is not the desired behavior then you use a different join.&lt;/P&gt;
&lt;P&gt;Again this is partially informational in case you did not intend the Cartesian join as they can be very resource intensive. Two data sets of 1000 records each would require 1,000,000 comparisons for example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 14:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-Include-Exclude-criteria-in-control-data-set/m-p/838069#M331400</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-12T14:41:20Z</dc:date>
    </item>
  </channel>
</rss>

