<?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: Query to filter data on reporting quarter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722557#M224068</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Is there a way to achieve it without touching the macro variable reportingdate1&lt;FONT color="#a67f59"&gt;. I&lt;FONT color="#000000"&gt; don't want to format the value of reportingdate1 macro variable as you mentioned.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token macro-keyword keyword"&gt;%let&lt;/SPAN&gt; reportingdate1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token macro-keyword keyword"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function keyword"&gt;inputn&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;20170331&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;yymmdd8&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Mar 2021 11:39:55 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2021-03-01T11:39:55Z</dc:date>
    <item>
      <title>Query to filter data on reporting quarter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722549#M224064</link>
      <description>&lt;P&gt;Code below is working fine for the reporting date1 20171231. However I'm not seeing any data if reporting date1&amp;nbsp;is either 20170331 or 20170630 or 20170930 as %sysfunc in second datastep generates the&amp;nbsp; value of the variable POP as 01, 02, 03,04... with leading zeros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second datastep is not working if I remove putn and z2. Any help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm looking for solution in same method only as value of reporting date1 in real life is dynamic and it will be any of the quarter ending date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let Reportingdate1=20171231;

data have;
input POP $;
datalines;
1
2
3
4
5
6
7
8
9
10
11
12
;
run;

data want;
set have;
where POP  in  
("%sysfunc(putn(%substr(&amp;amp;Reportingdate1,5,2),Z2.))" 
 "%sysfunc(putn(%eval(%substr(&amp;amp;Reportingdate1,5,2)-1),Z2.))" 
 "%sysfunc(putn(%eval(%substr(&amp;amp;Reportingdate1,5,2)-2),Z2.))");  
run;

&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Mar 2021 09:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722549#M224064</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-03-01T09:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Query to filter data on reporting quarter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722551#M224066</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let reportingdate1=%sysfunc(inputn(20170331,yymmdd8.));

data want;
set have;
where month(&amp;amp;reportingdate1.) - 2 le input(pop,2.) le month(&amp;amp;reportingdate1.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Maxim 28: Macro Variables Need No Formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you had dates instead of month numbers, it would be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where qtr(pop) = qtr(&amp;amp;reportingdate1.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Maxim 33: Intelligent Data Makes for Intelligent Programs.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 10:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722551#M224066</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-01T10:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: Query to filter data on reporting quarter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722557#M224068</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Is there a way to achieve it without touching the macro variable reportingdate1&lt;FONT color="#a67f59"&gt;. I&lt;FONT color="#000000"&gt; don't want to format the value of reportingdate1 macro variable as you mentioned.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token macro-keyword keyword"&gt;%let&lt;/SPAN&gt; reportingdate1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token macro-keyword keyword"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function keyword"&gt;inputn&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;20170331&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;yymmdd8&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 11:39:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722557#M224068</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2021-03-01T11:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Query to filter data on reporting quarter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722560#M224069</link>
      <description>&lt;P&gt;If you want to keep that YYYYMMDD format, then you have to wrap the macro variable into a INPUT function everywhere you use it, just to make it usable with date functions.&lt;/P&gt;
&lt;P&gt;The best way to store a date (or time) in a macro variable is the raw, unformatted value.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 12:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722560#M224069</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-01T12:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Query to filter data on reporting quarter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722564#M224071</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292396"&gt;@David_Billa&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Is there a way to achieve it without touching the macro variable reportingdate1&lt;FONT color="#a67f59"&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How about this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
where 0&amp;lt;=%substr(&amp;amp;Reportingdate1,5,2)-input(POP,2.)&amp;lt;=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Mar 2021 12:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-filter-data-on-reporting-quarter/m-p/722564#M224071</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-01T12:43:47Z</dc:date>
    </item>
  </channel>
</rss>

