<?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: Assign a date to a macro variable and use it to subset the data from a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432239#M107034</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want(where=( Ship_Date &amp;gt;="&amp;amp;date_comp"d));
set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Formatted SAS dates which are text must be enclosed in single or double quotes, followed by the letter D (and since you are using a macro variable, it must be double quotes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can save yourself a bunch of coding by not formatting the macro variable as date9., just leave it as an integer.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2018 15:13:20 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-01-30T15:13:20Z</dc:date>
    <item>
      <title>Assign a date to a macro variable and use it to subset the data from a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432237#M107033</link>
      <description>&lt;P&gt;Hello Everyone&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to assign a date to a macro variable and using that macro variable to subset a data from a dataset. It's throwing me an error. Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/*Assigning the macro variable the 27th Jan 2018 date*/
%let date_comp= %SYSFUNC(INTNX(DAY,%SYSFUNC(TODAY()),-3),date9.);
%put &amp;amp;date_comp.;
27JAN2018

DATA want(where=( Ship_Date &amp;gt;=&amp;amp;date_comp.));
set have;
run;



&lt;/PRE&gt;&lt;P&gt;The want data is throwing me an error. This is the error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data want (where=(ship_date &amp;gt;=&amp;amp;date_comp.));
NOTE: Line generated by the macro variable "DATE_COMP".
1 27JAN2018
-------
22
76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;,
=, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE, LT, NE, OR, ^=, |, ||, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

3721 set have;
3722 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

ERROR: Syntax error while parsing WHERE clause.&lt;/PRE&gt;&lt;P&gt;Please help me with this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chandan Mishra&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 15:09:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432237#M107033</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2018-01-30T15:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a date to a macro variable and use it to subset the data from a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432239#M107034</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want(where=( Ship_Date &amp;gt;="&amp;amp;date_comp"d));
set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Formatted SAS dates which are text must be enclosed in single or double quotes, followed by the letter D (and since you are using a macro variable, it must be double quotes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can save yourself a bunch of coding by not formatting the macro variable as date9., just leave it as an integer.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 15:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432239#M107034</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-01-30T15:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a date to a macro variable and use it to subset the data from a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432240#M107035</link>
      <description>&lt;PRE&gt;DATA want(where=( Ship_Date &amp;gt;= "&amp;amp;date_comp."d));&lt;/PRE&gt;
&lt;P&gt;Is the update you need, however why bother at all, it does nothing more than:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  where ship_date &amp;gt; today()-3;
runl&lt;/PRE&gt;
&lt;P&gt;Except making the code far harder to read, maintain and debug.&amp;nbsp; KISS - Keep It Simple Smart - is a mantra you should as programmer live by!&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 15:13:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432240#M107035</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-30T15:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a date to a macro variable and use it to subset the data from a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432242#M107036</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;
&lt;PRE&gt;DATA want(where=( Ship_Date &amp;gt;="&amp;amp;date_comp."d));&lt;/PRE&gt;
&lt;P&gt;The macro variable, itself, only contains text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 15:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432242#M107036</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-30T15:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Assign a date to a macro variable and use it to subset the data from a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432246#M107040</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your amazing reply. I am using a master file to run all the separate codes and want data is in the separate code. It's only because I don't have to change the code every time in the separate code, I used a macro variable in the master file and using it in the separate code. But I understood what you want to say. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chandan Mishra&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 15:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-a-date-to-a-macro-variable-and-use-it-to-subset-the-data/m-p/432246#M107040</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2018-01-30T15:19:36Z</dc:date>
    </item>
  </channel>
</rss>

