<?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: Ignore missing values in IF-THEN statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567067#M11434</link>
    <description>&lt;P&gt;A numeric missing value is smaller than any non-missing number, so expand your condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF . &amp;lt; DTP1 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS you might contemplate switching to lower-case coding, it's easier to read.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2019 21:01:09 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-06-18T21:01:09Z</dc:date>
    <item>
      <title>Ignore missing values in IF-THEN statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567065#M11432</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am comparing a subset of data and want to create an error message depending on certain criteria. I want to ignore missing values however, and currently SAS is reading the missing values in my if then statement. Is there a do-loop or array that can ignore these missing values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset containing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DOB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DTP1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DTP2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DTP3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DTP4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 2/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 4/25/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6/26/2017&lt;/P&gt;&lt;P&gt;1/13/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 01/16/2016&amp;nbsp; &amp;nbsp; 4/15/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I want to create variable ERROR = "DTP_ERROR" when any DTP1-DTP4 are less than 6 weeks after DOB.&lt;/P&gt;&lt;P&gt;Currently, below is my coding. However, it seems like SAS is ignoring my first "IF/THEN/DO" statement and counting missing variables as less than my , creating false errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA CLEANING.DATECOMPARE;&lt;BR /&gt;SET CLEANING.ALLVAX;&lt;BR /&gt;DATE6WK = HS_DOB + 42;&lt;BR /&gt;FORMAT DATE6WK DATE9.;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA CLEANING.DATE_DTP;&lt;BR /&gt;SET CLEANING.DATECOMPARE;&lt;BR /&gt;IF DTP1-DTP4 NE . THEN DO;&lt;BR /&gt;IF DTP1 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/P&gt;&lt;P&gt;IF DTP2 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/P&gt;&lt;P&gt;IF DTP3 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/P&gt;&lt;P&gt;IF DTP4 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;BR /&gt;END;&lt;BR /&gt;IF ERROR NE " " THEN OUTPUT;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 20:38:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567065#M11432</guid>
      <dc:creator>TPayne</dc:creator>
      <dc:date>2019-06-18T20:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore missing values in IF-THEN statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567067#M11434</link>
      <description>&lt;P&gt;A numeric missing value is smaller than any non-missing number, so expand your condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF . &amp;lt; DTP1 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS you might contemplate switching to lower-case coding, it's easier to read.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 21:01:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567067#M11434</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-18T21:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore missing values in IF-THEN statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567069#M11435</link>
      <description>&lt;P&gt;Sounds like you are confused.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First SAS always treats missing numeric values as less any actual number.&amp;nbsp; Run this little program to see.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 do x=-1,0,1,.,.a,.z,._ ;
   output;
 end;
run;
proc sort; by x; run;
data _null_;
 set test;
 put _n_= x= ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So fix your conditions to account for that fact.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF .Z &amp;lt; DTP1 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or using the MISSING() function might be clearer.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF DTP1 &amp;lt; DATE6WK and not missing(DTP1) THEN ERROR = 'DTP_DOSE';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also why are you testing whether the difference between DPT1 and DPT4 is missing?&amp;nbsp; That will be true when either value is missing.&amp;nbsp; Did you instead want to test if they are all missing?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;N(of DPT1-DPT4)=0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or any of them is missing?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NMISS(of DPT1-DPT4)&amp;gt;0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2019 21:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567069#M11435</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-18T21:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore missing values in IF-THEN statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567108#M11444</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;and I want to create variable ERROR = "DTP_ERROR" when any DTP1-DTP4 are less than 6 weeks after DOB.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can simplify this logic to take the minimum value and see if the&amp;nbsp;minimum is less than 6 weeks after the DOB. Unless you need to know which date is less, which&amp;nbsp;is still relatively easy.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA CLEANING.DATECOMPARE;
SET CLEANING.ALLVAX;

MIN_DATE = min(of dtp1-dtp4);

if min_date &amp;lt; (HS_DOB+42) then error = 'DTP_DOSE';


RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/278418"&gt;@TPayne&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am comparing a subset of data and want to create an error message depending on certain criteria. I want to ignore missing values however, and currently SAS is reading the missing values in my if then statement. Is there a do-loop or array that can ignore these missing values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset containing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DOB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DTP1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DTP2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DTP3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DTP4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 2/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 4/25/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8/24/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6/26/2017&lt;/P&gt;
&lt;P&gt;1/13/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; 01/16/2016&amp;nbsp; &amp;nbsp; 4/15/2016&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and I want to create variable ERROR = "DTP_ERROR" when any DTP1-DTP4 are less than 6 weeks after DOB.&lt;/P&gt;
&lt;P&gt;Currently, below is my coding. However, it seems like SAS is ignoring my first "IF/THEN/DO" statement and counting missing variables as less than my , creating false errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA CLEANING.DATECOMPARE;&lt;BR /&gt;SET CLEANING.ALLVAX;&lt;BR /&gt;DATE6WK = HS_DOB + 42;&lt;BR /&gt;FORMAT DATE6WK DATE9.;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA CLEANING.DATE_DTP;&lt;BR /&gt;SET CLEANING.DATECOMPARE;&lt;BR /&gt;IF DTP1-DTP4 NE . THEN DO;&lt;BR /&gt;IF DTP1 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/P&gt;
&lt;P&gt;IF DTP2 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/P&gt;
&lt;P&gt;IF DTP3 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;/P&gt;
&lt;P&gt;IF DTP4 &amp;lt; DATE6WK THEN ERROR = 'DTP_DOSE';&lt;BR /&gt;END;&lt;BR /&gt;IF ERROR NE " " THEN OUTPUT;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 01:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567108#M11444</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-06-19T01:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Ignore missing values in IF-THEN statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567245#M11468</link>
      <description>&lt;P&gt;Thank you, that worked!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 13:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ignore-missing-values-in-IF-THEN-statement/m-p/567245#M11468</guid>
      <dc:creator>TPayne</dc:creator>
      <dc:date>2019-06-19T13:07:27Z</dc:date>
    </item>
  </channel>
</rss>

