<?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: Date function error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353104#M82399</link>
    <description>&lt;P&gt;Aside from the fact that you are comparing date and datetime values, which will not work as expected, you do not need the date/datetime literal formatting in macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
start_date = today() - 2;
end_date = today() - 2;
if weekday(start_date) = 1 then start_day = start_day - 1;
call symput('dt',put(start_date,best.));
call symput('dt1',put(end_date,best.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;stores the raw date values as simple numbers, which are semantically the same. And it avoids all the hassles with the quotes.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2017 06:20:27 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-04-25T06:20:27Z</dc:date>
    <item>
      <title>Date function error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353095#M82393</link>
      <description>I have a function that's is giving me a date range when I pull it I get and error&lt;BR /&gt;&lt;BR /&gt;DATA _null; start_date=today()-2;&lt;BR /&gt;End_date=today ()-2;&lt;BR /&gt;If weekday (start_date)=1 then start_day=start_day-1;&lt;BR /&gt;Call symput ('dt', "'"||put (start_date, date.)||"'d'");&lt;BR /&gt;Call symput ('dt1', "'"||put (End_date, date.)||"'d'");&lt;BR /&gt;&lt;BR /&gt;The orderdate is a datetime20 format&lt;BR /&gt;(ts '2017-04-18 00:00:00:000)&lt;BR /&gt;My where statement&lt;BR /&gt;Where al1.order_date between &amp;amp;dt. And &amp;amp;dt1.&lt;BR /&gt;Log&lt;BR /&gt;Macro variable dt resolves to '22apr17'd&lt;BR /&gt;&lt;BR /&gt;Syntax error: expected something between a string or Unicode character literal and word 'd'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 25 Apr 2017 04:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353095#M82393</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2017-04-25T04:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Date function error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353098#M82395</link>
      <description>&lt;P&gt;Im not following your question, the where statement and the orderdate your are referring to are not in your code? Post your entire code and some sample data if necesarry&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 05:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353098#M82395</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-04-25T05:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: Date function error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353099#M82396</link>
      <description>Hi thanks for responding ..the data null on top would give me the date I need since it's a minus -2 it will give me sat day ...The order_date is a datetime20 format&lt;BR /&gt;(ts '2017-04-18 00:00:00:000)&lt;BR /&gt;Where al1.order_date between &amp;amp;dt. And &amp;amp;dt1.</description>
      <pubDate>Tue, 25 Apr 2017 05:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353099#M82396</guid>
      <dc:creator>Gil_</dc:creator>
      <dc:date>2017-04-25T05:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Date function error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353100#M82397</link>
      <description>&lt;P&gt;Several issues to consider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, instead of using DATE. as the format, use DATE9. as the format. &amp;nbsp;That way your macro variable will resolve to '22apr2017'd (including a four-digit year is safer).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, you cannot accurately compare a datetime to a date. &amp;nbsp;They take on a different range of values. &amp;nbsp;If ORDER_DATE is truly a datetime, you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Where datepart(al1.order_date) between &amp;amp;dt. And &amp;amp;dt1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Third, it's not clear what is in ORDER_DATE (is it really a datetime, a character string, or something else entirely). &amp;nbsp;But if it's really a datetime, the combination of the earlier steps should work.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 05:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353100#M82397</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-25T05:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Date function error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353104#M82399</link>
      <description>&lt;P&gt;Aside from the fact that you are comparing date and datetime values, which will not work as expected, you do not need the date/datetime literal formatting in macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
start_date = today() - 2;
end_date = today() - 2;
if weekday(start_date) = 1 then start_day = start_day - 1;
call symput('dt',put(start_date,best.));
call symput('dt1',put(end_date,best.));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;stores the raw date values as simple numbers, which are semantically the same. And it avoids all the hassles with the quotes.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 06:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353104#M82399</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-25T06:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Date function error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353118#M82407</link>
      <description>&lt;P&gt;Whilst your question has been answered, I am going to ask you this question. &amp;nbsp;You have logic to determine start and end date, so why are you going through the process of creating macro variables of the resolved logic, then using that in your program. &amp;nbsp;This is simple using macro for the sake of using macro, it adds nothing but complication to an otherwise simple statement. &amp;nbsp;This all derives down to:&lt;/P&gt;
&lt;P&gt;where a1.order_date = today() - 2;&lt;/P&gt;
&lt;P&gt;(assumes order date is numeric). &amp;nbsp;So why do you have all that extra code doing absolutely nothing? &amp;nbsp;Even if end date is different to start (which it isn't in your example):&lt;/P&gt;
&lt;P&gt;where a1_order_date between today() -2 and today() + 2;&lt;/P&gt;
&lt;P&gt;Still doesn't need all the faff.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 08:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-function-error/m-p/353118#M82407</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-25T08:08:01Z</dc:date>
    </item>
  </channel>
</rss>

