<?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: Macro and proc sql help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232961#M42483</link>
    <description>Also, please note that you could put those intnx functions directly into the WHERE clause instead of using macro variables.</description>
    <pubDate>Tue, 03 Nov 2015 20:24:48 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-11-03T20:24:48Z</dc:date>
    <item>
      <title>Macro and proc sql help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232946#M42470</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to filter dates in &amp;nbsp;proc sql using macro variables. &amp;nbsp;I could use some help getting it to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;MP4DB= intnx ('month',today(),-4,'B');&lt;BR /&gt;MP2DE= intnx ('month',today(),-2,'E');&lt;BR /&gt;call symput ('MP4DB', MP4DB);&lt;BR /&gt;Call Symput ('MP2DE', MP2DE);&lt;BR /&gt;Call symput ('MP4DB_DDMMYYS8', cats(put(MP4DB, ddmmyys8.))); &amp;nbsp;&amp;nbsp;&lt;BR /&gt;Call symput ('MP2DE_DDMMYYS8', cats(put(MP2DE, ddmmyys8.)));&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;%put _user_;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; PROC SQL;&lt;BR /&gt; CREATE TABLE WORK.total_test AS &lt;BR /&gt; SELECT DISTINCT t1.MEMID, &lt;BR /&gt; t1.MBR_LAST, &lt;BR /&gt; t1.MBR_FIRST, &lt;BR /&gt; /* SUM_of_ALLOW */&lt;BR /&gt; (SUM(t1.ALLOW)) AS SUM_of_ALLOW, &lt;BR /&gt; /* SUM_of_PAID */&lt;BR /&gt; (SUM(t1.PAID)) AS SUM_of_PAID&lt;BR /&gt; FROM WORK.COST_BY_MEMBERS t1&lt;BR /&gt; &lt;STRONG&gt;WHERE t1.ADMITDT BETWEEN ___________________________&lt;/STRONG&gt;&lt;BR /&gt; GROUP BY t1.MEMID&lt;BR /&gt; ORDER BY SUM_of_PAID DESC;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i use my begining and end dates&amp;nbsp;from the macro variables&amp;nbsp;in the where clause? &amp;nbsp;I have tried several ways and cant get it to work.&amp;nbsp; Any resources would be appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 19:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232946#M42470</guid>
      <dc:creator>Jse</dc:creator>
      <dc:date>2015-11-03T19:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and proc sql help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232948#M42471</link>
      <description>Remember that it has to resolve to valid SAS code. If the dates are SAS dates, numbers, then the following works. If you apply formats, then you need to make sure they resolve to appropriate date literals in SAS.&lt;BR /&gt;&lt;BR /&gt;&amp;amp;MP4DB and &amp;amp;MP2DE</description>
      <pubDate>Tue, 03 Nov 2015 19:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232948#M42471</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-03T19:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and proc sql help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232951#M42474</link>
      <description>&lt;P&gt;Hi mate,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it is simply you add a max and min function into your SQL and use then in the having&amp;nbsp;clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  format date date9.;
  input date :date9.;
  cards;
01jan2015
02jan2015
30jan2015
;
run;

proc sql;
   select date, max(date) as max_date format=date9.,
   		  min(date) as min format=date9. from test
		  having date between min(date) and max(date);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try this. Having clause can use summary functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 19:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232951#M42474</guid>
      <dc:creator>DartRodrigo</dc:creator>
      <dc:date>2015-11-03T19:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and proc sql help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232961#M42483</link>
      <description>Also, please note that you could put those intnx functions directly into the WHERE clause instead of using macro variables.</description>
      <pubDate>Tue, 03 Nov 2015 20:24:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232961#M42483</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-03T20:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro and proc sql help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232962#M42484</link>
      <description>Thank you Reeza, you are a tremendous help.  Much appreciated.</description>
      <pubDate>Tue, 03 Nov 2015 20:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-and-proc-sql-help/m-p/232962#M42484</guid>
      <dc:creator>Jse</dc:creator>
      <dc:date>2015-11-03T20:26:59Z</dc:date>
    </item>
  </channel>
</rss>

