<?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: Issue in resolving date variable in where clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142340#M28531</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Change to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%let year1 =%sysfunc(intnx(month,%sysfunc(today()),-12),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 May 2014 14:05:45 GMT</pubDate>
    <dc:creator>slchen</dc:creator>
    <dc:date>2014-05-02T14:05:45Z</dc:date>
    <item>
      <title>Issue in resolving date variable in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142339#M28530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;Old query&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Data x ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;set y;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;where Offer_St_dt &amp;gt;= '01OCT2011'd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;run; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;I am trying to replace the above query with &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;New Query&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%let year1 = %STR(%')%sysfunc(intnx(month,%sysfunc(today()),-12),date9.)%STR(%'); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Data x ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;set y;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;where Offer_St_dt &amp;gt;= &amp;amp;year1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;run; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;I am getting error in the above case as &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;ERROR: Syntax error while parsing WHERE clause.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, (, +, -, :, INPUT, NOT, PUT, ^, ~. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 14:00:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142339#M28530</guid>
      <dc:creator>archana</dc:creator>
      <dc:date>2014-05-02T14:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in resolving date variable in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142340#M28531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Change to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;%let year1 =%sysfunc(intnx(month,%sysfunc(today()),-12),date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 14:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142340#M28531</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2014-05-02T14:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in resolving date variable in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142341#M28532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not write it in data step?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;Data x ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;set y;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;where Offer_St_dt &amp;gt;=&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;intnx('month',today(),-12)&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 14:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142341#M28532</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-05-02T14:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in resolving date variable in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142342#M28533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not working. i am getting the same error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 14:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142342#M28533</guid>
      <dc:creator>archana</dc:creator>
      <dc:date>2014-05-02T14:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in resolving date variable in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142343#M28534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your macro approach, you forgot the d at the end of the date literal, and you need to manually %unquote() the macro variable (this is an old macro language bug, it should unquote it for you but sometime it doesn't... when code from MPRINT looks right but fails, try %unquote().&amp;nbsp;&amp;nbsp; Ksharp's non macro approach works for me as well.&amp;nbsp; Code below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;%let year1 = %STR(%')%sysfunc(intnx(month,%sysfunc(today()),-12),date9.)%STR(%')d; 

data have;
&amp;nbsp; Offer_St_dt="01Jan2012"d; output;
&amp;nbsp; Offer_St_dt="01Jan2014"d; output;
run;

%put &amp;amp;year1;

data want ;
&amp;nbsp; set have;
&amp;nbsp; where Offer_St_dt &amp;gt;= %unquote(&amp;amp;year1);
run; 

data want2 ;
&amp;nbsp; set have;
&amp;nbsp; where Offer_St_dt &amp;gt;=intnx('month',today(),-12)&amp;nbsp;&amp;nbsp; ;
run;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 14:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142343#M28534</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2014-05-02T14:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in resolving date variable in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142344#M28535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A more easier approach would be setting some global macro variables by a sas-datastep.&lt;BR /&gt;When this is a standard approach it could be a standard setting part of sas start.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By that you can verify the content of the macro var. Leave it as text&amp;nbsp; and put the quotes and d indication when needed&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 15:29:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142344#M28535</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-05-02T15:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Issue in resolving date variable in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142345#M28536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why are you using single quotes instead of double quotes?&amp;nbsp; Macro references do not resolve inside of single quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let year1 = "%sysfunc(intnx(month,%sysfunc(today()),-12),date9.)"d ;&lt;/P&gt;&lt;P&gt;Data x ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set y;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where Offer_St_dt &amp;gt;= &amp;amp;year1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 May 2014 15:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Issue-in-resolving-date-variable-in-where-clause/m-p/142345#M28536</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-05-02T15:53:21Z</dc:date>
    </item>
  </channel>
</rss>

