<?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: Select quarterly data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/812194#M320438</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks again but in the output if you see dates are coming as march, dec, september, june but we are expecting it to be like&lt;STRONG&gt; jan, apr, July, October.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try playing around with the INTNX parameters to get what you need. Your quarters are not standard quarters, it's using the end of the first month of a quarter it seems. Typical quarters are Jan 1 - March 31.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code structure is correct, you need to modify the parameters within INTNX to get what you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the documentation for reference. If you cannot figure it out, post what you've tried and we can help from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p10v3sa3i4kfxfn1sovhi5xzxh8n.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p10v3sa3i4kfxfn1sovhi5xzxh8n.htm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 09 May 2022 15:48:13 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-05-09T15:48:13Z</dc:date>
    <item>
      <title>Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811914#M320298</link>
      <description>&lt;P&gt;Hi There I have a scenario where I need to create and run a program to load quarterly data. So I need to write a code to load historical quarterly data. For eg if I run today the code to should get me the data for last 7 quarters. So looking to create a macro&amp;nbsp; with input current run date and accordingly it will get me last 7 quarter's dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;format y date9.;&lt;/P&gt;&lt;P&gt;y = intx('qtr',&amp;amp;rep_date.,0,'e');&lt;/P&gt;&lt;P&gt;put y ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;kajal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 17:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811914#M320298</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2022-05-06T17:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811915#M320299</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
*end of previous quarter;
report_end_date = intnx('qtr', today(), -1, 'e');
*start of 8 quarters ago (if you want 7 quarters);
report_start_end = intnx('qtr', today(), -8, 'b');

format report_: date9.;

call symputx('report_start_dt', report_start_date);
call symputx('report_end_dt', report_end_date);

run;

*will show as numbers but work fine as filters;
%put &amp;amp;report_start_dt.;
%put &amp;amp;report_end_dt.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like above should get you started. You can modify the increments as needed or change the alignment parameters to get the start/end dates.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi There I have a scenario where I need to create and run a program to load quarterly data. So I need to write a code to load historical quarterly data. For eg if I run today the code to should get me the data for last 7 quarters. So looking to create a macro&amp;nbsp; with input current run date and accordingly it will get me last 7 quarter's dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data one;&lt;/P&gt;
&lt;P&gt;format y date9.;&lt;/P&gt;
&lt;P&gt;y = intx('qtr',&amp;amp;rep_date.,0,'e');&lt;/P&gt;
&lt;P&gt;put y ;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;kajal&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 17:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811915#M320299</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-06T17:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811919#M320302</link>
      <description>&lt;P&gt;Thanks Reeza for your very quick reply but I forgot to add one more point here as quarters are fiscal quarters like 1st -qtr april, 2nd&amp;nbsp;-qtr july, 3rd -qtr october, 4th -qtr january&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 17:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811919#M320302</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2022-05-06T17:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811921#M320303</link>
      <description>&lt;P&gt;Show sample data and expected output please. Fake data is fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variable types (numeric/character) and format may be relevant as well.&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 17:17:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811921#M320303</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-06T17:17:30Z</dc:date>
    </item>
    <item>
      <title>Re: Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811924#M320305</link>
      <description>&lt;P&gt;Sorry accidently accepted as solution.&lt;/P&gt;&lt;P&gt;so I have like 100 quarterly files out of which user wants to select as per demand files. file names have quarter end dates like.&lt;/P&gt;&lt;P&gt;So here let say I am selecting files for last 7 quarters&lt;/P&gt;&lt;P&gt;customer_scn_bb_bdk_20220430.xls,&lt;/P&gt;&lt;P&gt;customer_scn_bb_bdk_20220131.xls&lt;/P&gt;&lt;P&gt;customer_scn_bb_bdk_20220730.xls&lt;/P&gt;&lt;P&gt;customer_scn_bb_bdk_20210131.xls&lt;/P&gt;&lt;P&gt;customer_scn_bb_bdk_20210430.xls&lt;/P&gt;&lt;P&gt;customer_scn_bb_bdk_20210731.xls&lt;/P&gt;&lt;P&gt;customer_scn_bb_bdk_20211031.xls&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if I can create a table of date values as per given start date I can choose files accordingly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kajal&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 17:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811924#M320305</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2022-05-06T17:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811925#M320306</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data list_dates;
*end of previous quarter;

do i=1 to 7;
report_end_date = intnx('qtr', today(), -1*i, 'e');
output;
end;

format report_end_date yymmddn8.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Full import/combine code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data list_dates;
*end of previous quarter;

do i=1 to 7;
report_end_date = intnx('qtr', today(), -1*i, 'e');
file_name = catt('customer_scn_bb_bdk', put(report_end_date, yymmddn8.), '.xlsx');

str = catt('proc import out=qtr', i, ' datafile="', file_name, ' dbms=xlsx replace; run;');

call execute(str);
end;

format report_end_date yymmddn8.;
run;

data last7qtrs;
set qtr1-qtr7;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 May 2022 17:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811925#M320306</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-06T17:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811926#M320307</link>
      <description>&lt;P&gt;Thanks again but in the output if you see dates are coming as march, dec, september, june but we are expecting it to be like&lt;STRONG&gt; jan, apr, July, October.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 18:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811926#M320307</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2022-05-06T18:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811943#M320317</link>
      <description>&lt;P&gt;Just loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = -6 to 0;
  y = intx('qtr',&amp;amp;rep_date.,i,'e');
  /* whatever you intend to do */
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 May 2022 21:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/811943#M320317</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-06T21:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select quarterly data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/812194#M320438</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259983"&gt;@kajal_30&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks again but in the output if you see dates are coming as march, dec, september, june but we are expecting it to be like&lt;STRONG&gt; jan, apr, July, October.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try playing around with the INTNX parameters to get what you need. Your quarters are not standard quarters, it's using the end of the first month of a quarter it seems. Typical quarters are Jan 1 - March 31.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code structure is correct, you need to modify the parameters within INTNX to get what you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the documentation for reference. If you cannot figure it out, post what you've tried and we can help from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p10v3sa3i4kfxfn1sovhi5xzxh8n.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/p10v3sa3i4kfxfn1sovhi5xzxh8n.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 May 2022 15:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-quarterly-data/m-p/812194#M320438</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-05-09T15:48:13Z</dc:date>
    </item>
  </channel>
</rss>

