<?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 Date calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425170#M104714</link>
    <description>&lt;P&gt;I've two variables called Reporting_dt and&amp;nbsp;premium_begin_date.&amp;nbsp;If the year of the premium_begin_date is less than the Reporting_dt year then the begin date is the 1&lt;SUP&gt;st&lt;/SUP&gt; of January of the reporting year else keep the &lt;SPAN&gt;premium_begin_date.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g. if Reporting_dt = ‘31/08/2013’ and the &lt;SPAN&gt;premium_begin_date&lt;/SPAN&gt;&amp;nbsp;is 01/11/2012 then the begin date = ‘&lt;U&gt;01/01&lt;/U&gt;/2013’.&lt;/P&gt;
&lt;P&gt;e.g. if Reporting_dt = ‘31/08/2013’ and the &lt;SPAN&gt;premium_begin_date&lt;/SPAN&gt;&amp;nbsp;is 01/04/2013 then the begin date = ‘&lt;U&gt;01/04&lt;/U&gt;/2013’.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate if someone help me to accomplish this.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2018 10:25:59 GMT</pubDate>
    <dc:creator>Babloo</dc:creator>
    <dc:date>2018-01-05T10:25:59Z</dc:date>
    <item>
      <title>Date calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425170#M104714</link>
      <description>&lt;P&gt;I've two variables called Reporting_dt and&amp;nbsp;premium_begin_date.&amp;nbsp;If the year of the premium_begin_date is less than the Reporting_dt year then the begin date is the 1&lt;SUP&gt;st&lt;/SUP&gt; of January of the reporting year else keep the &lt;SPAN&gt;premium_begin_date.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g. if Reporting_dt = ‘31/08/2013’ and the &lt;SPAN&gt;premium_begin_date&lt;/SPAN&gt;&amp;nbsp;is 01/11/2012 then the begin date = ‘&lt;U&gt;01/01&lt;/U&gt;/2013’.&lt;/P&gt;
&lt;P&gt;e.g. if Reporting_dt = ‘31/08/2013’ and the &lt;SPAN&gt;premium_begin_date&lt;/SPAN&gt;&amp;nbsp;is 01/04/2013 then the begin date = ‘&lt;U&gt;01/04&lt;/U&gt;/2013’.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate if someone help me to accomplish this.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 10:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425170#M104714</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-01-05T10:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Date calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425174#M104716</link>
      <description>&lt;P&gt;do like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Reporting_dt premium_begin_date)(:ddmmyy10.);
format Reporting_dt premium_begin_date ddmmyy10.;
datalines;
31/08/2013 01/11/2012
31/08/2013 01/04/2013
;

data want;
	set have;
	begin_date=premium_begin_date;
	if year(Reporting_dt) &amp;gt; year(premium_begin_date) then begin_date=mdy(1, 1, year(Reporting_dt));
	format begin_date ddmmyy10.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425174#M104716</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-05T11:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Date calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425182#M104717</link>
      <description>&lt;P&gt;Classic case for using ifn() function here on a binary result:&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;  set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  begin_date&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;ifn(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Reporting_dt&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;premium_begin_date&lt;SPAN class="token punctuation"&gt;),&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mdy&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;Reporting_dt&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;),premium_begin_date)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;  format&lt;/SPAN&gt; begin_date ddmmyy10&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 11:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425182#M104717</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-05T11:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Date calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425261#M104740</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I've two variables called Reporting_dt and&amp;nbsp;premium_begin_date.&amp;nbsp;If the year of the premium_begin_date is less than the Reporting_dt year then the begin date is the 1&lt;SUP&gt;st&lt;/SUP&gt; of January of the reporting year else keep the &lt;SPAN&gt;premium_begin_date.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g. if Reporting_dt = ‘31/08/2013’ and the &lt;SPAN&gt;premium_begin_date&lt;/SPAN&gt;&amp;nbsp;is 01/11/2012 then the begin date = ‘&lt;U&gt;01/01&lt;/U&gt;/2013’.&lt;/P&gt;
&lt;P&gt;e.g. if Reporting_dt = ‘31/08/2013’ and the &lt;SPAN&gt;premium_begin_date&lt;/SPAN&gt;&amp;nbsp;is 01/04/2013 then the begin date = ‘&lt;U&gt;01/04&lt;/U&gt;/2013’.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate if someone help me to accomplish this.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want to use a hard coded date in code the form is 'ddMONyy'd or 'ddMONyyyy'd. Examples: '23Feb98'd or '16May2017'd.&lt;/P&gt;
&lt;P&gt;the D after quote tells SAS to attempt to use the value inside the quotes as a Date. The specific format is because there are so many ways to display dates and several of them are not readily identifiable in context such as "010203" which could be 02Jan2003, 01Feb2003, or 03Feb2001.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may find the PDF document on here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; helpful for date use.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 15:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-calculation/m-p/425261#M104740</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-05T15:51:36Z</dc:date>
    </item>
  </channel>
</rss>

