<?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: Multiple conditions IF in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/848020#M335279</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411017"&gt;@znhnm&lt;/a&gt;&amp;nbsp;Everything works for me. See the example code below.&lt;BR /&gt;Please share your sample data code and log to get help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
informat date1 date2 datetime26.;
format date1 date2 datetime26.;
input date1 date2;
datalines;
15AUG2022:00:00:00.000000 14AUG2022:00:00:00.000000
;
run;

data example2;
set example;
if (((date1 &amp;gt; '01JAN2022:00:00:00.000000'dt AND date1 &amp;lt; "31DEC2022:00:00:00.000000"dt) OR (missing(date1)))
OR ((date2 &amp;gt; '01JAN2022:00:00:00.000000'dt AND date2 &amp;lt; "31DEC2022:00:00:00.000000"dt) OR (missing(date2))));
run;
proc print data=example2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Dec 2022 03:00:45 GMT</pubDate>
    <dc:creator>Sajid01</dc:creator>
    <dc:date>2022-12-06T03:00:45Z</dc:date>
    <item>
      <title>Multiple conditions IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/847862#M335198</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to apply one filter on date1 and another filter on date2 and creating an OR selection between them. The below syntax is not working properly. The code runs but the filter on date2 is not applied to the data. What would be the right syntax?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data example2;
set example;
if (((date1 &amp;gt; '01JAN2022:00:00:00.000000'dt AND date1 &amp;lt; "31DEC2022:00:00:00.000000"dt) OR (missing(date1)))
OR ((date2 &amp;gt; '01JAN2022:00:00:00.000000'dt AND date2 &amp;lt; "31DEC2022:00:00:00.000000"dt) OR (missing(date2))));
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 18:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/847862#M335198</guid>
      <dc:creator>znhnm</dc:creator>
      <dc:date>2022-12-05T18:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/847867#M335200</link>
      <description>&lt;P&gt;Are variables DATE1 and DATE2 both date/time values? What format is applied to them? If you remove the format, what is a typical value of DATE2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they are both date/time values, we would need to see a portion of your data set to determine what the problem is, and we would need to know what the desired outcome is. Please provide data as working SAS data step code, which you can type in yourself or follow &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;. Attachments and screen captures are not acceptable ways to share data.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 18:10:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/847867#M335200</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-05T18:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/847871#M335201</link>
      <description>&lt;P&gt;As you saw in writing your code, it's clumsy to refer to datetime values.&amp;nbsp; You can further see this by looking at the conditions you selected, since dates that fall on December 31, 2022 are (probably) being deleted improperly.&amp;nbsp; I would suggest simplifying and getting rid of the datetimes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example2;
   set example;
   if missing(date1) or missing(date2) or year(datepart(date1))=2022 or year(datepart(date2))=2022;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2022 18:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/847871#M335201</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-12-05T18:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple conditions IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/848020#M335279</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411017"&gt;@znhnm&lt;/a&gt;&amp;nbsp;Everything works for me. See the example code below.&lt;BR /&gt;Please share your sample data code and log to get help.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
informat date1 date2 datetime26.;
format date1 date2 datetime26.;
input date1 date2;
datalines;
15AUG2022:00:00:00.000000 14AUG2022:00:00:00.000000
;
run;

data example2;
set example;
if (((date1 &amp;gt; '01JAN2022:00:00:00.000000'dt AND date1 &amp;lt; "31DEC2022:00:00:00.000000"dt) OR (missing(date1)))
OR ((date2 &amp;gt; '01JAN2022:00:00:00.000000'dt AND date2 &amp;lt; "31DEC2022:00:00:00.000000"dt) OR (missing(date2))));
run;
proc print data=example2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Dec 2022 03:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-conditions-IF/m-p/848020#M335279</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-12-06T03:00:45Z</dc:date>
    </item>
  </channel>
</rss>

