<?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: Create  a Macro to resolve date ranges to use in Proc SQL in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266746#M18487</link>
    <description>&lt;P&gt;Put your "data" in a dataset and then use that. &amp;nbsp;Macro code is for generating SAS code, not for processing data&amp;amp;colon;&lt;/P&gt;
&lt;PRE&gt;data dates;
  lower=intnx('day',"&amp;amp;sysdate."d,-9);
  upper=intnx('day',"&amp;amp;sysdate."d,-3);
run;

proc sql;
  ...
  from ORACLE_DATABASE
  where  (select LOWER from DATES) &amp;lt;= datepart(TRANS_DATE) &amp;lt;= (select UPPER from DATES);
quit;
&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Apr 2016 15:26:59 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-04-27T15:26:59Z</dc:date>
    <item>
      <title>Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266731#M18484</link>
      <description>&lt;P&gt;I created below macro &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options symbolgen;&lt;BR /&gt;%let T1 = %sysfunc(intnx(Day,"&amp;amp;sysdate"d,-9),mmddyy10);&lt;BR /&gt;%let T2 = %sysfunc(intnx(Day,"&amp;amp;sysdate"d,-3),mmddyy10);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to bring records for previous week from oracle database ( has millions of records)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql ;&lt;/P&gt;
&lt;P&gt;where datepart(a.trans_dt) &amp;gt;= &amp;amp;&lt;SPAN&gt;T1&lt;/SPAN&gt; AND datepart(a.trans_dt) &amp;lt;= &amp;amp;&lt;SPAN&gt;T2&lt;/SPAN&gt; &lt;BR /&gt; order by a.trans_dt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;brings zero rows.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;trans_dt&amp;nbsp;&lt;/SPAN&gt; is datetime variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I resolve? Please help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we are using EG5.1 &amp;nbsp;/ SAS 9.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if I use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where (datepart(&lt;SPAN&gt;a.trans_dt&lt;/SPAN&gt;) &amp;gt;= intnx('week',today(),-1,'b') &lt;BR /&gt; AND datepart(&lt;SPAN&gt;a.trans_dt&lt;/SPAN&gt;) &amp;lt;=intnx('week',today(),-1,'e')); I get 64 rows but takes 2 hrs &amp;nbsp;-- &amp;nbsp;Hope it helps to understand&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 14:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266731#M18484</guid>
      <dc:creator>avatar</dc:creator>
      <dc:date>2016-04-27T14:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266733#M18485</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remove the format from the macro code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently your macro variables look like mmddyy10, but that wouldn't work in the query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where datepart(a.trans_dt) &amp;gt;= &amp;amp;T1 AND datepart(a.trans_dt) &amp;lt;= &amp;amp;T2 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Becomes the following, which isn't valid SAS code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where datepart(a.trans_dt) &amp;gt;= 04/16/2016
 AND datepart(a.trans_dt) &amp;lt;= 04/22/2016
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead use the following which creates SAS date values as the number of days since Jan 1, 1960. If you really want to see the date format use date9 and then add quotes and the letter do to the values in your Where clause ("&amp;amp;t2"d).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let T1 = %sysfunc(intnx(Day,"&amp;amp;sysdate"d,-9));
%let T2 = %sysfunc(intnx(Day,"&amp;amp;sysdate"d,-3));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 14:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266733#M18485</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-27T14:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266746#M18487</link>
      <description>&lt;P&gt;Put your "data" in a dataset and then use that. &amp;nbsp;Macro code is for generating SAS code, not for processing data&amp;amp;colon;&lt;/P&gt;
&lt;PRE&gt;data dates;
  lower=intnx('day',"&amp;amp;sysdate."d,-9);
  upper=intnx('day',"&amp;amp;sysdate."d,-3);
run;

proc sql;
  ...
  from ORACLE_DATABASE
  where  (select LOWER from DATES) &amp;lt;= datepart(TRANS_DATE) &amp;lt;= (select UPPER from DATES);
quit;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 15:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266746#M18487</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-27T15:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266749#M18488</link>
      <description>&lt;P&gt;yes. I didnot get results from previous code. I Will give this a try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 15:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266749#M18488</guid>
      <dc:creator>avatar</dc:creator>
      <dc:date>2016-04-27T15:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266750#M18489</link>
      <description>Got this error:&lt;BR /&gt;&lt;BR /&gt;AND datepart(a.trans_dt) &amp;gt;= "&amp;amp;T1"d&lt;BR /&gt;SYMBOLGEN:  Macro variable T1 resolves to 20562&lt;BR /&gt;ERROR: Invalid date/time/datetime constant "20562"d.&lt;BR /&gt;75                 AND datepart(a.trans_dt) &amp;lt;= "&amp;amp;T2"d)&lt;BR /&gt;SYMBOLGEN:  Macro variable T2 resolves to 20568&lt;BR /&gt;ERROR: Invalid date/time/datetime constant "20568"d.&lt;BR /&gt;76               order by a.trans_dt;&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Apr 2016 15:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266750#M18489</guid>
      <dc:creator>avatar</dc:creator>
      <dc:date>2016-04-27T15:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266758#M18490</link>
      <description>&lt;P&gt;%let START_DATE ='17APR2016'd;&lt;BR /&gt;%let END_DATE ='23APR2016'd;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;where&amp;nbsp;(a.trans_dt &amp;gt;=&amp;amp;START_DATE.) and (a.trans_dt &amp;lt;=&amp;amp;END_DATE. )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this works. but I want run for previous week from today. any other solution?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 16:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266758#M18490</guid>
      <dc:creator>avatar</dc:creator>
      <dc:date>2016-04-27T16:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266766#M18491</link>
      <description>&lt;P&gt;Either of these will work.&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 T1 = %sysfunc(intnx(Day,"&amp;amp;sysdate"d,-9));
%let T2 = %sysfunc(intnx(Day,"&amp;amp;sysdate"d,-3));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep your where clause as originally designed, T1/T2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where (a.trans_dt &amp;gt;=&amp;amp;T1.) and (a.trans_dt &amp;lt;=&amp;amp;T2. )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, if you really insist:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let T1 = %sysfunc(intnx(Day,"&amp;amp;sysdate"d,-9), date9.);
%let T2 = %sysfunc(intnx(Day,"&amp;amp;sysdate"d,-3), date9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And your where clause becomes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where (a.trans_dt &amp;gt;="&amp;amp;T1"d) and (a.trans_dt &amp;lt;="&amp;amp;T2"d)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 16:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266766#M18491</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-27T16:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266773#M18492</link>
      <description>AND (a.trans_dt) &amp;gt;= &amp;amp;T1. AND (a.trans_dt) &amp;lt;= &amp;amp;T2.&lt;BR /&gt;SYMBOLGEN:  Macro variable T1 resolves to 20562&lt;BR /&gt;SYMBOLGEN:  Macro variable T2 resolves to 20568&lt;BR /&gt;79               order by a.trans_dt;&lt;BR /&gt;NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.&lt;BR /&gt;NOTE: Table WORK.SPARCS_RETURN created, with 0 rows and 29 columns.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Apr 2016 17:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266773#M18492</guid>
      <dc:creator>avatar</dc:creator>
      <dc:date>2016-04-27T17:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266777#M18493</link>
      <description>&lt;P&gt;Sorry, you still need the datepart in your where clause. It was there in your original question, but removed later on for some reason?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;AND datepart(a.trans_dt) &amp;gt;= &amp;amp;T1. AND datepart(a.trans_dt) &amp;lt;= &amp;amp;T2.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you go the other route (date9) you need the datepart as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008080"&gt;Your query before shows it works with date9 format and no datepart so I don't know. Maybe the dates created aren't what you need? Try using the date9 format and see what dates are created vs what you need, maybe the intnx needs to change.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 17:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266777#M18493</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-27T17:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266783#M18494</link>
      <description>Actually ,It worked without datepart in&lt;BR /&gt;(a.trans_dt) &amp;gt;="&amp;amp;T1"d AND (a.trans_dt) &amp;lt;="&amp;amp;T2"d&lt;BR /&gt;If I use datepart ---- keeps running  no results&lt;BR /&gt;</description>
      <pubDate>Wed, 27 Apr 2016 17:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266783#M18494</guid>
      <dc:creator>avatar</dc:creator>
      <dc:date>2016-04-27T17:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266869#M18496</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10529"&gt;@avatar&lt;/a&gt; wrote:&lt;BR /&gt;Actually ,It worked without datepart in&lt;BR /&gt;(a.trans_dt) &amp;gt;="&amp;amp;T1"d AND (a.trans_dt) &amp;lt;="&amp;amp;T2"d&lt;BR /&gt;If I use datepart ---- keeps running no results&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the criterion without "datepart" is satisfied by&amp;nbsp;one or more observations, it is virtually certain that a.trans_dt is &lt;EM&gt;not&lt;/EM&gt; a SAS datetime value (contrary to what the&amp;nbsp;statement "&lt;SPAN&gt;trans_dt&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt; is datetime variable" in your initial post suggested). So, I would examine what the trans_dt values really&amp;nbsp;&lt;EM&gt;are&lt;/EM&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Looking at the log excerpt in your previous post, containing the line&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;AND (a.trans_dt) &amp;gt;= &amp;amp;T1. AND (a.trans_dt) &amp;lt;= &amp;amp;T2.&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;and indicating a result of "0 rows," I'm wondering what (restrictive?) condition you applied before the first "AND."&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 21:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266869#M18496</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-27T21:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266934#M18499</link>
      <description>AND (a.trans_dt &amp;gt;="&amp;amp;T1"d) and (a.trans_dt &amp;lt;="&amp;amp;T2"d)&lt;BR /&gt;SYMBOLGEN:  Macro variable T1 resolves to 17APR2016&lt;BR /&gt;SYMBOLGEN:  Macro variable T2 resolves to 23APR2016&lt;BR /&gt;74               order by a.trans_dt;&lt;BR /&gt;&lt;BR /&gt;TRANS_DT  in the report has datetime values&lt;BR /&gt;18APR2016:13:04:02&lt;BR /&gt;19APR2016:06:58:14&lt;BR /&gt;19APR2016:07:01:50&lt;BR /&gt;19APR2016:07:03:54&lt;BR /&gt;20APR2016:07:40:59&lt;BR /&gt;21APR2016:09:59:10&lt;BR /&gt;21APR2016:14:39:43&lt;BR /&gt;22APR2016:11:06:25&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Apr 2016 13:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266934#M18499</guid>
      <dc:creator>avatar</dc:creator>
      <dc:date>2016-04-28T13:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266943#M18500</link>
      <description>&lt;P&gt;Still, if TRANS_DT contained these datetimes as &lt;EM&gt;SAS datetime values&lt;/EM&gt;, these would be numbers &amp;gt;1000000000. On the other hand, '23APR2016'd=20567. So, the inequality&amp;nbsp;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;a.trans_dt &amp;lt;="&amp;amp;T2"d&lt;/FONT&gt; would not hold.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would make sure that these inequalities are evaluated as expected, looking at unformatted values.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 13:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266943#M18500</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-28T13:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266949#M18501</link>
      <description>Tried with datepart and got zero rows.  Not sure which one to use . Please advise.&lt;BR /&gt;  AND datepart(a.trans_dt &amp;gt;="&amp;amp;T1"d) and datepart(a.trans_dt &amp;lt;="&amp;amp;T2"d))&lt;BR /&gt;SYMBOLGEN:  Macro variable T1 resolves to 17APR2016&lt;BR /&gt;SYMBOLGEN:  Macro variable T2 resolves to 23APR2016&lt;BR /&gt;74               order by a.trans_dt;&lt;BR /&gt;NOTE: Table WORK.SPARCS_RETURN created, with 0 rows and 29 columns.&lt;BR /&gt;&lt;BR /&gt;75         QUIT;&lt;BR /&gt;</description>
      <pubDate>Thu, 28 Apr 2016 13:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266949#M18501</guid>
      <dc:creator>avatar</dc:creator>
      <dc:date>2016-04-28T13:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create  a Macro to resolve date ranges to use in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266954#M18502</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10529"&gt;@avatar&lt;/a&gt; wrote:&lt;BR /&gt;Tried with datepart and got zero rows. Not sure which one to use . Please advise.&lt;BR /&gt; AND datepart(a.trans_dt &amp;gt;="&amp;amp;T1"d) and datepart(a.trans_dt &amp;lt;="&amp;amp;T2"d))&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You must not use the inequality as the argument of the DATEPART function. This would mean datepart(1) or datepart(0) (depending on whether the inequality is true or false), both of which are 0, i.e. FALSE (as a Boolean value).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;AND datepart(a.trans_dt&lt;STRONG&gt;)&lt;/STRONG&gt; &amp;gt;="&amp;amp;T1"d and datepart(a.trans_dt&lt;STRONG&gt;)&lt;/STRONG&gt; &amp;lt;="&amp;amp;T2"d&lt;/PRE&gt;
&lt;P&gt;The above line would make sense logically, but only if a.trans_dt contains SAS datetime values, which has still not&amp;nbsp;been&amp;nbsp;verified. Not trial and error, but an examination of the &lt;EM&gt;unformatted&lt;/EM&gt; values of variable TRANS_DT should clarify this: Just select TRANS_DT from the database and apply PROC MEANS to this variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;[Edit: improved wording]&lt;/P&gt;</description>
      <pubDate>Thu, 28 Apr 2016 15:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Create-a-Macro-to-resolve-date-ranges-to-use-in-Proc-SQL/m-p/266954#M18502</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-28T15:30:24Z</dc:date>
    </item>
  </channel>
</rss>

