<?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: Filter date value based on Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522516#M141871</link>
    <description>&lt;P&gt;Well, you haven't told us a lot ... is TRANS_DATE numeric?&amp;nbsp; What should happen if &amp;amp;REPORTING_DT falls in the middle of the month.&amp;nbsp; Do you need to use SQL, or will a DATA step suffice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So making a guess as to the answers, here is an approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;where intnx('month', "&amp;amp;reporting_dt"d, 0) &amp;lt;= trans_date &amp;lt;= "&amp;amp;reporting_dt"d;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Dec 2018 14:19:46 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-12-19T14:19:46Z</dc:date>
    <item>
      <title>Filter date value based on Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522509#M141866</link>
      <description>&lt;P&gt;I've a macro as follows.&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;%let reporting_dt=30JUN2018&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then I've to filter the below variable and it should be between 01jun2018 to 30jun2018 of the 'reporting_dt'. I don't want to hard code anything here as the value of the macro variable changes frequently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Trans_date&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;01jun2018&lt;BR /&gt;08jul2017&lt;BR /&gt;30apr2018&lt;BR /&gt;27jun2018&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Desired output:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Trans_date&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;01jun2018&lt;BR /&gt;27jun2018&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 13:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522509#M141866</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-19T13:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Filter date value based on Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522513#M141868</link>
      <description>&lt;P&gt;AS with every other post, please show test data in the form of a datastep.&amp;nbsp; Now, once again we have to have this back and forth as we try to extract the required information from you as to what the data is!!&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is trans_date?&amp;nbsp; Is it a character or a numeric?&amp;nbsp; How are you filtering the data?&lt;/P&gt;
&lt;P&gt;If its a date then:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  where trans_date="&amp;amp;reporting_dt."d;
run;&lt;/PRE&gt;
&lt;P&gt;If its character:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  where upcase(trans_dt)="&amp;amp;reporting_dt.";
run;&lt;/PRE&gt;
&lt;P&gt;In future, please&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;post test data in the form of a datastep, show what output you want, show the code you have used, and any log output which occurs.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 14:02:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522513#M141868</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-19T14:02:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filter date value based on Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522515#M141870</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've a macro as follows.&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;%let reporting_dt=30JUN2018&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It will help everyone if we&amp;nbsp;all are using the same (and correct) terminology.&amp;nbsp;You do NOT have a macro. You have a macro variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Then I've to filter the below variable and it should be between 01jun2018 to 30jun2018&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So how does the macro variable relate to the above sentence? There is more information in the above sentence than there is in the macro variable. Where does this extra information come from? We need to understand the logic in order to provide working code.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 14:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522515#M141870</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-12-19T14:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Filter date value based on Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522516#M141871</link>
      <description>&lt;P&gt;Well, you haven't told us a lot ... is TRANS_DATE numeric?&amp;nbsp; What should happen if &amp;amp;REPORTING_DT falls in the middle of the month.&amp;nbsp; Do you need to use SQL, or will a DATA step suffice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So making a guess as to the answers, here is an approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;where intnx('month', "&amp;amp;reporting_dt"d, 0) &amp;lt;= trans_date &amp;lt;= "&amp;amp;reporting_dt"d;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 14:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522516#M141871</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-19T14:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Filter date value based on Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522546#M141889</link>
      <description>TRANS_DATE is numeric variable. I need all the dates of the reporting month&lt;BR /&gt;in TRANS_DATE. Data step or proc sql, anything is OK&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Dec 2018 15:05:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522546#M141889</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2018-12-19T15:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Filter date value based on Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522577#M141899</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;TRANS_DATE is numeric variable. I need all the dates of the reporting month&lt;BR /&gt;in TRANS_DATE. Data step or proc sql, anything is OK&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It sounds like you are looking for something like:&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   where intnx('month',"&amp;amp;reporting_dt."d,0,'B') le trans_date le  intnx('month',"&amp;amp;reporting_dt."d,0,'E');
run;&lt;/PRE&gt;
&lt;P&gt;Which assumes that your trans_date is SAS date valued.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 15:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filter-date-value-based-on-Macro/m-p/522577#M141899</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-19T15:34:11Z</dc:date>
    </item>
  </channel>
</rss>

