<?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: How to calculate a fiscal month given a specific date using a calculated column in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555424#M33615</link>
    <description>&lt;P&gt;Thanks so much! This worked like a charm (and a much cleaner solution than my original attempt)&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2019 17:31:36 GMT</pubDate>
    <dc:creator>TelecomSasUser</dc:creator>
    <dc:date>2019-05-01T17:31:36Z</dc:date>
    <item>
      <title>How to calculate a fiscal month given a specific date using a calculated column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555271#M33606</link>
      <description>&lt;P&gt;In SAS Enterprise Guide, I'm trying to create a calculated column that converts a date (in the DATETIME26.6 format) to a date format fiscal month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the day is the 1st through the 21st of the month, I want the fiscal month to be the first day of that month.&lt;/P&gt;&lt;P&gt;If the day is the 22nd through the 31st of the month, I want the fiscal month to be the first day of THE NEXT month&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example, Jan 21st 2019 should return Jan 1st 2019&lt;/P&gt;&lt;P&gt;And Jan 22nd 2019 should return Feb 1st 2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've written the code and tested both the INTNX and comparison in pieces (and they've worked), but when I include it in a case statement, my returns are all coming out as '."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or analogously, if there's a better way of doing this, I'm happy to adopt a new solution altogether!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CASE
	WHEN DAY(DATEPART(t3.CRE_DT))&amp;lt;22
		THEN 	
			INTNX(	'DAY', 
				t3.CRE_DT, 
				1-DAY(DATEPART(t3.CRE_DT))
			)
	WHEN DAY(DATEPART(t3.CRE_DT))&amp;gt;=22
		THEN
			INTNX(	'MONTH', 
				INTNX(	'DAY', DATEPART(t3.CRE_DT), 1-DAY(DATEPART(t3.CRE_DT)), 
				1
			)
END&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2019 04:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555271#M33606</guid>
      <dc:creator>TelecomSasUser</dc:creator>
      <dc:date>2019-05-01T04:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a fiscal month given a specific date using a calculated column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555367#M33614</link>
      <description>&lt;P&gt;No need for a CASE statement at all. Consider IFN function in below.&lt;/P&gt;
&lt;PRE&gt;data example;
   do CRE_DT='01JAN2019:12:15:00'dt to '31Jan2019:12:15:00'dt by 3600;
      newdate = ifn(day(datepart(CRE_DT))&amp;lt;22,datepart(intnx('dtmonth',CRE_DT,0,'B')),datepart(intnx('dtmonth',CRE_DT,1,'B')),.);
      output;
   end;
   format CRE_DT datetime19.  newdate date9.;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your t3.CRE_DT variable is a DATETIME the proper interval would be 'DTDAY' or 'DTMONTH'&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 14:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555367#M33614</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-01T14:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a fiscal month given a specific date using a calculated column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555424#M33615</link>
      <description>&lt;P&gt;Thanks so much! This worked like a charm (and a much cleaner solution than my original attempt)&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 17:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555424#M33615</guid>
      <dc:creator>TelecomSasUser</dc:creator>
      <dc:date>2019-05-01T17:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a fiscal month given a specific date using a calculated column</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555475#M33616</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272458"&gt;@TelecomSasUser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks so much! This worked like a charm (and a much cleaner solution than my original attempt)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm not generally a fan of the IFN and IFC functions as they can lead to some longish hard to read code (like this) but I have even more of an issue with CASE statements.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 20:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-calculate-a-fiscal-month-given-a-specific-date-using-a/m-p/555475#M33616</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-01T20:24:11Z</dc:date>
    </item>
  </channel>
</rss>

