<?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 Convert date to the monthend date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301483#M63814</link>
    <description>&lt;P&gt;How would I be able to change any date to a monthend date where the dd character is altered to the end of the month dd.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Sep 2016 10:06:00 GMT</pubDate>
    <dc:creator>Sharepoint007</dc:creator>
    <dc:date>2016-09-29T10:06:00Z</dc:date>
    <item>
      <title>Convert date to the monthend date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301483#M63814</link>
      <description>&lt;P&gt;How would I be able to change any date to a monthend date where the dd character is altered to the end of the month dd.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 10:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301483#M63814</guid>
      <dc:creator>Sharepoint007</dc:creator>
      <dc:date>2016-09-29T10:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date to the monthend date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301485#M63815</link>
      <description>Intnx() function solves this.</description>
      <pubDate>Thu, 29 Sep 2016 10:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301485#M63815</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-09-29T10:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date to the monthend date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301490#M63818</link>
      <description>&lt;P&gt;Comprehensive documentation of the intnx() fuction is found &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#p10v3sa3i4kfxfn1sovhi5xzxh8n.htm" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;You need to make sure that your dates are stored as &lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm" target="_blank"&gt;SAS date values&lt;/A&gt;, of course.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 10:28:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301490#M63818</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-29T10:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date to the monthend date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301516#M63828</link>
      <description>&lt;P&gt;If this is something you will be using often you may want to consider creating a user defined function to access it in the future. Here's an example of my version of this formula and a similar one that returns the First of the Month from either a date or a datetime value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	proc fcmp outlib = dmudfs.UDF.UDF;

		function FirstOfMonth(dt);
		/* 	Purpose: Return the first day of month from either a Date or DateTime argument*/
			if dt/86400 &amp;gt; 1 then FOM = intnx('day', datepart(dt), -day(datepart(dt)) + 1);
			else FOM = intnx('day', dt, -day(dt) + 1);
		return(FOM);
		endsub;

		function LastOfMonth(dt);
		/* 	Purpose: Return the last day of month from either a Date or DateTime argument*/
			if dt/86400 &amp;gt; 1 then LOM = intnx('day',intnx('month', intnx('day', datepart(dt), -day(datepart(dt)) + 1),1),-1);
			else LOM = intnx('day',intnx('month', intnx('day', dt, -day(dt) + 1),1),-1);
		return(LOM);
		endsub;

	quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dt/86400&amp;gt;1 as an indicator of date or datetime has served well thus far but there may be a more bulletproof approach.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To use the function include this line in your project, making sure to replace "dmudfs" to suit your setup:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options cmplib = dmudfs.UDF;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then you can call the function by using "LastOfMonth(mydate)".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 13:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301516#M63828</guid>
      <dc:creator>titus</dc:creator>
      <dc:date>2016-09-29T13:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: Convert date to the monthend date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301624#M63869</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/61630"&gt;@titus&lt;/a&gt; Idea of custom function isn't bad, but&amp;nbsp;I would 0 and the alignment parameter as in the documentation example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	proc fcmp outlib = dmudfs.UDF.UDF;

		function FirstOfMonth(dt);
		/* 	Purpose: Return the first day of month from either a Date or DateTime argument*/
			if dt/86400 &amp;gt; 1 then FOM = intnx('day', datepart(dt), 0, 'b');
			else FOM = intnx('day', dt, 0, 'b');
		return(FOM);
		endsub;

		function LastOfMonth(dt);
		/* 	Purpose: Return the last day of month from either a Date or DateTime argument*/
			if dt/86400 &amp;gt; 1 then LOM = intnx('day', datepart(dt), 0, 'e');
			else LOM = intnx('day', dt, 0, 'e');
		return(LOM);
		endsub;

	quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 19:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-date-to-the-monthend-date/m-p/301624#M63869</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-29T19:59:23Z</dc:date>
    </item>
  </channel>
</rss>

