<?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: Using an if statement with an AND in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344851#M79289</link>
    <description>&lt;P&gt;Let's start with the most obvious issues and clear them up. &amp;nbsp;There might be more, but start with ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is YEAR_DOB really a two-digit year? &amp;nbsp;That would be the only reason to use ?? MMDDYY8. &amp;nbsp;But if YEAR_DOB is really a four-digit year, MMDDYY8 isn't long enough. &amp;nbsp;You need to switch to MMDDYY10. because you have to count the slashes as part of the characters you are reading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you have switched around the month and the day. &amp;nbsp;It is highly unlikely that you will ever find MONTH_DOB=29.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Mar 2017 02:23:23 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-03-28T02:23:23Z</dc:date>
    <item>
      <title>Using an if statement with an AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344839#M79283</link>
      <description>&lt;P&gt;Total_DOB = input(catx("/", month_dob, day_dob, year_dob),?? mmddyy8.);&lt;BR /&gt;if ((month_dob = 29) AND (day_dob= 02)) then Total_DOB = mdy(03,01,year_dob)-1;&lt;BR /&gt;else Total_DOB = mdy(month_dob,15,year_dob);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Total_DOB = input(catx("/", month_dob, day_dob, year_dob),?? mmddyy8.);&lt;/DIV&gt;&lt;DIV&gt;if ((Total_DOB = .) AND (month_dob = 29)) then Total_DOB = mdy(03,01,year_dob)-1;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;else Total_DOB = mdy(month_dob,15,year_dob);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;neither work and just change all of the dates with a . to the day with 15&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Mar 2017 00:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344839#M79283</guid>
      <dc:creator>larkjr18</dc:creator>
      <dc:date>2017-03-28T00:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using an if statement with an AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344844#M79284</link>
      <description>&lt;P&gt;I would try the below approach if there are only two conditions&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) if the month_dob=02 and day_dob=29 then you want it to be imputed to 01MarYYYY. imputing only the day and month. if it is the case then what you mentioned is incorrect, you codes month_dob=29 which should be 02 as i mentioned so you reversed it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) if the above condition is not met then&amp;nbsp; you would like to impute only the day to 15.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if these are only two conditions you are checking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 01:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344844#M79284</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-03-28T01:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using an if statement with an AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344851#M79289</link>
      <description>&lt;P&gt;Let's start with the most obvious issues and clear them up. &amp;nbsp;There might be more, but start with ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is YEAR_DOB really a two-digit year? &amp;nbsp;That would be the only reason to use ?? MMDDYY8. &amp;nbsp;But if YEAR_DOB is really a four-digit year, MMDDYY8 isn't long enough. &amp;nbsp;You need to switch to MMDDYY10. because you have to count the slashes as part of the characters you are reading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you have switched around the month and the day. &amp;nbsp;It is highly unlikely that you will ever find MONTH_DOB=29.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 02:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344851#M79289</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-28T02:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using an if statement with an AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344871#M79297</link>
      <description>&lt;P&gt;Did you know that function MDY can handle two digits year values? If the problem is that you are sometimes missing the day value, then all you need is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Total_DOB = mdy (month_dob, coalesce(day_dob, 15), year_dob);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;format total_DOB yymmdd10.;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2017 04:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344871#M79297</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-03-28T04:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using an if statement with an AND</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344931#M79317</link>
      <description>&lt;P&gt;First of all, are month_dob, day_dob, year_dob numeric or character? In your code snippet you treat them as both, which is at least not sound programming practice.&lt;/P&gt;
&lt;P&gt;Assuming that they are numeric, I'd do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Total_DOB = input(put(year_dob,z4.) !! put(month_dob,z2.) !! put(day_dob,z2.),yymmdd8.);
if Total_DOB = .
then do;
  if ((month_dob = 29) and (day_dob = 2))
  then Total_DOB = mdy(3,1,year_dob)-1;
  else if day_dob = .
  then Total_DOB = mdy(month_dob,15,year_dob);
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Mar 2017 11:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-an-if-statement-with-an-AND/m-p/344931#M79317</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-28T11:27:48Z</dc:date>
    </item>
  </channel>
</rss>

