<?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: Quarter difference between two dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677580#M204402</link>
    <description>&lt;P&gt;Are you talking about calendar quarters, or fiscal quarters?&amp;nbsp;&amp;nbsp;&amp;nbsp; I ask this because, for a company whose fiscal year ends in (say) october, then the quarter difference between Jan (end of fiscal Q1) and Feb (start of fiscal Q2) is 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case you would need to adjust the argument ('QTR') in intck('qtr',begdate,enddate).&amp;nbsp; If, say you have a variable fyend_month (fiscal year end month, with values 1 to 12), you could:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
  interval==catx('.','qtr',mod(fyend_month,3)+1);
  nqtr=intck(interval,begdate,enddate);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This generates intervals of 'QTR.1' (equivalent to 'QTR'), 'QTR.2', or 'QTR.3'. These specify quarters as beginning in the first month of the calendar quarter ('qtr.1'), beginning in the second month of the calendar quarter ('qtr.2'), or the third ('qtr.3').&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Aug 2020 18:11:59 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2020-08-18T18:11:59Z</dc:date>
    <item>
      <title>Quarter difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677566#M204396</link>
      <description>&lt;P&gt;I would like to understand how to identify the quarter difference between two dates. I knew that it can achieved by intck function but I'm not certain how to accomplish with that function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose I've the data as given below. Both the variables are numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="140px" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="72.8px" height="19" style="height: 14.4pt; width: 48pt;"&gt;Start_qtr&lt;/TD&gt;
&lt;TD width="67.2px" style="width: 48pt;"&gt;End_qtr&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="72.8px" height="19" style="height: 14.4pt;"&gt;2017-03&lt;/TD&gt;
&lt;TD width="67.2px"&gt;2017-09&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="72.8px" height="19" style="height: 14.4pt;"&gt;2017-06&lt;/TD&gt;
&lt;TD width="67.2px"&gt;2018-03&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to calculate quarter difference by creating the new variable 'Qtr_diff' and it should have the value of difference between Start_qtr and End_qtr.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 144pt;" border="0" width="192" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="64" height="19" style="height: 14.4pt; width: 48pt;"&gt;Start_qtr&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;End_qtr&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Qtr_Diff&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" style="height: 14.4pt;"&gt;2017-03&lt;/TD&gt;
&lt;TD&gt;2017-09&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" style="height: 14.4pt;"&gt;2017-06&lt;/TD&gt;
&lt;TD&gt;2018-03&lt;/TD&gt;
&lt;TD align="right"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 18 Aug 2020 17:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677566#M204396</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2020-08-18T17:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Quarter difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677571#M204400</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Qtr_Diff=intck('qtr', start_qtr, end_qtr);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Aug 2020 17:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677571#M204400</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-08-18T17:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Quarter difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677580#M204402</link>
      <description>&lt;P&gt;Are you talking about calendar quarters, or fiscal quarters?&amp;nbsp;&amp;nbsp;&amp;nbsp; I ask this because, for a company whose fiscal year ends in (say) october, then the quarter difference between Jan (end of fiscal Q1) and Feb (start of fiscal Q2) is 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case you would need to adjust the argument ('QTR') in intck('qtr',begdate,enddate).&amp;nbsp; If, say you have a variable fyend_month (fiscal year end month, with values 1 to 12), you could:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
  interval==catx('.','qtr',mod(fyend_month,3)+1);
  nqtr=intck(interval,begdate,enddate);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This generates intervals of 'QTR.1' (equivalent to 'QTR'), 'QTR.2', or 'QTR.3'. These specify quarters as beginning in the first month of the calendar quarter ('qtr.1'), beginning in the second month of the calendar quarter ('qtr.2'), or the third ('qtr.3').&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 18:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677580#M204402</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-18T18:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Quarter difference between two dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677586#M204405</link>
      <description>Source data is connected with only calendar quarter.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 18 Aug 2020 18:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Quarter-difference-between-two-dates/m-p/677586#M204405</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2020-08-18T18:24:05Z</dc:date>
    </item>
  </channel>
</rss>

