<?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 WHERE statement - multiple statements in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784436#M39945</link>
    <description>&lt;P&gt;How do I exclude both EM codes and OP procedures from my data? Are the operators correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data HospOPDept;&lt;BR /&gt;set OUTPAT;&lt;BR /&gt;real_date=input(eventdate,YYMMDD10.);&lt;BR /&gt;/*format real_date date9.;*/&lt;BR /&gt;format real_date yyq6.; /*year-qtr*/&lt;BR /&gt;where rptGrouper not in ("OP Procedures")&lt;BR /&gt;or (cpt not between '99201' and '99215')&lt;BR /&gt;or (cpt not between '99241' and '99245')&lt;BR /&gt;or (cpt not between '99381' and '99397')&lt;BR /&gt;or (cpt not between '99354' and '99355')&lt;BR /&gt;or (cpt not between '99401' and '99412')&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 01:50:35 GMT</pubDate>
    <dc:creator>anonymous_user</dc:creator>
    <dc:date>2021-12-07T01:50:35Z</dc:date>
    <item>
      <title>WHERE statement - multiple statements</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784436#M39945</link>
      <description>&lt;P&gt;How do I exclude both EM codes and OP procedures from my data? Are the operators correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data HospOPDept;&lt;BR /&gt;set OUTPAT;&lt;BR /&gt;real_date=input(eventdate,YYMMDD10.);&lt;BR /&gt;/*format real_date date9.;*/&lt;BR /&gt;format real_date yyq6.; /*year-qtr*/&lt;BR /&gt;where rptGrouper not in ("OP Procedures")&lt;BR /&gt;or (cpt not between '99201' and '99215')&lt;BR /&gt;or (cpt not between '99241' and '99245')&lt;BR /&gt;or (cpt not between '99381' and '99397')&lt;BR /&gt;or (cpt not between '99354' and '99355')&lt;BR /&gt;or (cpt not between '99401' and '99412')&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 01:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784436#M39945</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2021-12-07T01:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE statement - multiple statements</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784438#M39946</link>
      <description>&lt;P&gt;Guessing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where rptGrouper not in ("OP Procedures")
AND ((cpt not between '99201' and '99215')
or (cpt not between '99241' and '99245')
or (cpt not between '99381' and '99397')
or (cpt not between '99354' and '99355')
or (cpt not between '99401' and '99412'))
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Dec 2021 01:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784438#M39946</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-07T01:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE statement - multiple statements</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784439#M39947</link>
      <description>&lt;P&gt;I used an "OR" operator but it's not excluding those codes or OP procedures...&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 02:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784439#M39947</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2021-12-07T02:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE statement - multiple statements</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784445#M39948</link>
      <description>&lt;P&gt;Try ANDs:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where rptGrouper not in ("OP Procedures")
and (cpt not between '99201' and '99215')
and (cpt not between '99241' and '99245')
and (cpt not between '99381' and '99397')
and (cpt not between '99354' and '99355')
and (cpt not between '99401' and '99412')
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Dec 2021 02:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784445#M39948</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-12-07T02:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE statement - multiple statements</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784474#M39949</link>
      <description>&lt;P&gt;It might be a good idea to provide some example data, the basic rules (not code when you don't have code that works) and an example of the output for the example data.&lt;/P&gt;
&lt;P&gt;It may be that you need more parentheses for grouping related concepts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://brilliant.org/wiki/de-morgans-laws/" target="_blank"&gt;https://brilliant.org/wiki/de-morgans-laws/&lt;/A&gt;&amp;nbsp; may help a bit to work out some details of OR , AND combinations of logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This "trick" of converting your values to numeric, assuming all of the values you need to test follow the 5 digit examples, may help simplify the code:&lt;/P&gt;
&lt;PRE&gt;data have;
   input x $;
datalines;
99123
99124
99125 
99127
99234
99235
99236
99237
;

data example;
   set have;
   where input(x,f5.) not in (99123:99125 99234:99236);
run;
&lt;/PRE&gt;
&lt;P&gt;The IN operator will accept numeric ranges, indicated by the : between two integers to select integer values and might considerably reduce the amount of code needed. The above code excludes values and is what I think could replace&lt;/P&gt;
&lt;PRE&gt;(cpt not between '99123' and '99125')
and (cpt not between '99234' and '99236')&lt;/PRE&gt;
&lt;P&gt;Personally I will go out my way to do any comparisons with text values and ranges as they so seldom work nicely. If every single value has the exact same number of characters then maybe.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 06:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784474#M39949</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-07T06:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE statement - multiple statements</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784567#M39950</link>
      <description>&lt;P&gt;Here's what I did and it worked (I created a macro for the codes instead of listing them out and did a "where also" statement to exclude those codes in addition to excluding OP Procedures):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data HospOPDept;&lt;BR /&gt;set OUTPAT;&lt;BR /&gt;real_date=input(eventdate,YYMMDD10.);&lt;BR /&gt;/*format real_date date9.;*/&lt;BR /&gt;format real_date yyq6.; /*year-qtr*/&lt;BR /&gt;where rptGrouper not in ("OP Procedures");&lt;BR /&gt;where also cpt not in &amp;amp;EMCODES;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 16:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/WHERE-statement-multiple-statements/m-p/784567#M39950</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2021-12-07T16:54:26Z</dc:date>
    </item>
  </channel>
</rss>

