<?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: Choosing the Previous Quarter End using INTNX in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365735#M86908</link>
    <description>Thanks! Worked!</description>
    <pubDate>Fri, 09 Jun 2017 15:32:12 GMT</pubDate>
    <dc:creator>camfarrell25</dc:creator>
    <dc:date>2017-06-09T15:32:12Z</dc:date>
    <item>
      <title>Choosing the Previous Quarter End using INTNX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365704#M86892</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm currently trying to set up a process that given the date chosen in the prompt (&amp;amp;ReportDate), it gives me the previous quarter last day.&lt;/P&gt;&lt;P&gt;For example, the prompt allows me to choose either Quarter End (March 31, June 30, September 30, December 30) and then the DateInfLag variables should correspond to the last day of the previous quarter (December 31, March 31, June 30 and September 30, respectively).&lt;/P&gt;&lt;P&gt;Although, the problem is that in the case of June 30 reports, the intnx function brings back "March 30" instead of "March 31".&lt;/P&gt;&lt;P&gt;Any ideas??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select distinct 
/*Reporting Period - One quarter lag*/
compress(tranwrd(put(intnx('qtr',"&amp;amp;ReportDate"d,-1,'same'),yymmdd10.),"-","")),
compress(tranwrd(put(intnx('year',intnx('qtr',"&amp;amp;ReportDate"d,-1,'same'),-1,'same'),yymmdd10.),"-","")),
compress(tranwrd(put(intnx('year',intnx('qtr',"&amp;amp;ReportDate"d,-1,'same'),-2,'same'),yymmdd10.),"-","")),
compress(tranwrd(put(intnx('year',intnx('qtr',"&amp;amp;ReportDate"d,-1,'same'),-3,'same'),yymmdd10.),"-","")),
compress(tranwrd(put(intnx('year',intnx('qtr',"&amp;amp;ReportDate"d,-1,'same'),-4,'same'),yymmdd10.),"-","")),
/*Reporting Year*/
compress(put(year("&amp;amp;ReportDate"d),4.),"-",""), 
substr(compress(tranwrd(put(intnx('year',"&amp;amp;ReportDate"d,-1,'same'),yymmdd10.),"-","")),1,4),
substr(compress(tranwrd(put(intnx('year',"&amp;amp;ReportDate"d,-2,'same'),yymmdd10.),"-","")),1,4),
substr(compress(tranwrd(put(intnx('year',"&amp;amp;ReportDate"d,-3,'same'),yymmdd10.),"-","")),1,4),
substr(compress(tranwrd(put(intnx('year',"&amp;amp;ReportDate"d,-4,'same'),yymmdd10.),"-","")),1,4)
into: DateInflag1, : DateInflag2 , : DateInflag3, : DateInflag4, : DateInflag5, : Year1, :Year2, :Year3, :Year4,:Year5
from _PRODSAVAIL;
quit; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 14:46:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365704#M86892</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2017-06-09T14:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing the Previous Quarter End using INTNX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365718#M86898</link>
      <description>&lt;P&gt;SAME says to return the same day. Try 'E' for end of period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also get rid of a lot of code manipulation if you use the YYMMDD&lt;STRONG&gt;N. format.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if this is goes into a data set strongly recommend keeping dates as date values not text.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 15:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365718#M86898</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-09T15:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing the Previous Quarter End using INTNX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365719#M86899</link>
      <description>&lt;P&gt;Your INTNX functions are using SAME as the 4 parameter.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use END to align the dates to the END of the quarter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you're passing JUNE 30th as a report date, it will give you the 30th, the same, of whatever month. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: I honestly don't know that I've ever seen someone do their dates in SQL. A data _null_ step would probably be easier to read/maintain in my opinion. For example, your source dataset has absolutely no reason to be in that data step but you're forced to use that in SQL. There is no such requirement in a data step, and you can use loops for the reptitive calculations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 
do i=1 to 4;
    dateinFlag = ...... ;

    Year = year(dateinFlag);

   call symputx("dateinFlag"||i, dateInFlag);
   call symputx('Year'||i, year);

end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 15:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365719#M86899</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-09T15:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing the Previous Quarter End using INTNX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365721#M86901</link>
      <description>&lt;P&gt;If you use the alignment option of INTNX to be 'END' (or 'e' for short), you should get March 31. That's what I get.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 15:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365721#M86901</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-06-09T15:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing the Previous Quarter End using INTNX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365726#M86904</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   format end_last_q date9.;
   end_last_q = intnx('qtr', today(), -1, 'end');
   put end_last_q;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2017 15:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365726#M86904</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-09T15:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing the Previous Quarter End using INTNX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365734#M86907</link>
      <description>Thank you!!</description>
      <pubDate>Fri, 09 Jun 2017 15:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365734#M86907</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2017-06-09T15:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing the Previous Quarter End using INTNX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365735#M86908</link>
      <description>Thanks! Worked!</description>
      <pubDate>Fri, 09 Jun 2017 15:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365735#M86908</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2017-06-09T15:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Choosing the Previous Quarter End using INTNX</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365736#M86909</link>
      <description>Thanks!!</description>
      <pubDate>Fri, 09 Jun 2017 15:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Choosing-the-Previous-Quarter-End-using-INTNX/m-p/365736#M86909</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2017-06-09T15:32:19Z</dc:date>
    </item>
  </channel>
</rss>

