<?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 How to get a complete date from a partial date by comparing with another date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-complete-date-from-a-partial-date-by-comparing-with/m-p/350167#M81364</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to get the complete aedate from the partial available aedate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If year is same and month is greater than trtdate then add 01 as day to aedate&lt;/P&gt;&lt;P&gt;If year is same and month is less than trtdate then add 15 as day to aedate&lt;/P&gt;&lt;P&gt;If year is and month is same than &amp;nbsp;aedate=trtdate&lt;/P&gt;&lt;P&gt;if year is greater than year of trtdate then&amp;nbsp;&lt;SPAN&gt;add 01 as day to aedate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help. Thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output needed;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp;aedate &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; trtdate&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; 2016-11-01 &amp;nbsp; 09JUL2016&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp;2016-06-15 &amp;nbsp; &amp;nbsp;17JUL2016&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp;2016-07-17 &amp;nbsp; &amp;nbsp;17JUL2016&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp;2017-01 -01 &amp;nbsp; &amp;nbsp;25NOV2016&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data one;
input id aedate $ trtdate date9.;
datalines;
1 2016-11 09JUL2016
2 2016-06 17JUL2016
3 2016-07 17JUL2016
4 2017-01 25NOV2016
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Apr 2017 19:27:25 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2017-04-14T19:27:25Z</dc:date>
    <item>
      <title>How to get a complete date from a partial date by comparing with another date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-complete-date-from-a-partial-date-by-comparing-with/m-p/350167#M81364</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to get the complete aedate from the partial available aedate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If year is same and month is greater than trtdate then add 01 as day to aedate&lt;/P&gt;&lt;P&gt;If year is same and month is less than trtdate then add 15 as day to aedate&lt;/P&gt;&lt;P&gt;If year is and month is same than &amp;nbsp;aedate=trtdate&lt;/P&gt;&lt;P&gt;if year is greater than year of trtdate then&amp;nbsp;&lt;SPAN&gt;add 01 as day to aedate&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help. Thank you&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output needed;&lt;/P&gt;&lt;P&gt;id &amp;nbsp; &amp;nbsp;aedate &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; trtdate&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; 2016-11-01 &amp;nbsp; 09JUL2016&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp;2016-06-15 &amp;nbsp; &amp;nbsp;17JUL2016&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp;2016-07-17 &amp;nbsp; &amp;nbsp;17JUL2016&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp;2017-01 -01 &amp;nbsp; &amp;nbsp;25NOV2016&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data one;
input id aedate $ trtdate date9.;
datalines;
1 2016-11 09JUL2016
2 2016-06 17JUL2016
3 2016-07 17JUL2016
4 2017-01 25NOV2016
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 19:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-complete-date-from-a-partial-date-by-comparing-with/m-p/350167#M81364</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-04-14T19:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a complete date from a partial date by comparing with another date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-complete-date-from-a-partial-date-by-comparing-with/m-p/350176#M81367</link>
      <description>&lt;P&gt;Try this code. It works for the scenarios where year is greater or equal to&amp;nbsp;trtdate year, but you have not specified what should happen if aedate year is less than trtdate year:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input id aedate $ trtdate date9.;
format trtdate date9.;
datalines;
1 2016-11 09JUL2016
2 2016-06 17JUL2016
3 2016-07 17JUL2016
4 2017-01 25NOV2016
;

data two;
set one;
format aedaten yymmdd10.;
aedaten = mdy(substr(aedate,6),01,substr(aedate,1,4));  /* create a date variable with 01 as the default day */
if year(aedaten)=year(trtdate) then do;
	if month(aedaten)&amp;lt;month(trtdate) then aedaten=aedaten+14;
	if month(aedaten)=month(trtdate) then aedaten=aedaten+16;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Apr 2017 19:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-a-complete-date-from-a-partial-date-by-comparing-with/m-p/350176#M81367</guid>
      <dc:creator>nehalsanghvi</dc:creator>
      <dc:date>2017-04-14T19:51:00Z</dc:date>
    </item>
  </channel>
</rss>

