<?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: &amp;quot;Extract From date&amp;quot; Breaking my Macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444130#M282912</link>
    <description>&lt;P&gt;Hi thanks for replying i got the Extract from terdata which is where i coded the SQL, so is the problem that I am using TERADATA functions in SAS?&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2018 14:37:04 GMT</pubDate>
    <dc:creator>lloydsanford</dc:creator>
    <dc:date>2018-03-09T14:37:04Z</dc:date>
    <item>
      <title>"Extract From date" Breaking my Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444075#M282908</link>
      <description>&lt;P&gt;I have the below code that seems not to work the error seems to the "FROM" in my macro EXTRACT (Year FROM &amp;lt;DATE&amp;gt;) see the error below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;75    EXTRACT(MONTH FROM ADD_MONTHS(CURRENT_DATE,0))
                    ----
                    22
                    202
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, BETWEEN, CONTAINS, EQ, EQT, GE, GET, GT, GTT,
              IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.

ERROR 202-322: The option or parameter is not recognized and will be ignored&lt;/PRE&gt;&lt;P&gt;This is the code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;rsubmit;
%macro monmac (month=,tablename=, year=);
proc sql;

create table homedir.Table2 as 
(select 

subproduct,
travel_year,
travel_month,
brx_anclry_rev_vlu

FROM Homedir.Anc_Flown_All

WHERE travel_year = &amp;amp;year.
AND travel_month = &amp;amp;month.);
quit;
%mend monmac;
endrsubmit;

rsubmit;
%monmac(tablename = Forecast1, month = EXTRACT(MONTH FROM ADD_MONTHS(CURRENT_DATE,0)),year = EXTRACT(YEAR FROM ADD_MONTHS(CURRENT_DATE,0)))
run;
endrsubmit; 



&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 13:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444075#M282908</guid>
      <dc:creator>lloydsanford</dc:creator>
      <dc:date>2018-03-09T13:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: "Extract From date" Breaking my Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444108#M282909</link>
      <description>&lt;P&gt;Doesn't really have anything to do with macro variable or macro processing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is not EXTRACT() function that is supported by PROC SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to do?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 14:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444108#M282909</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-09T14:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: "Extract From date" Breaking my Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444113#M282910</link>
      <description>&lt;P&gt;And where do you get this extract() function and syntax from?&amp;nbsp; Is it MySql or Oracle or something?&amp;nbsp; SAS proc sql only supports ANSI SQL and SAS functions.&amp;nbsp; What I think you want is something like:&lt;/P&gt;
&lt;PRE&gt;%monmac (month=,tablename=,year=);&lt;BR /&gt;&lt;BR /&gt;proc sql;
  create table homedir.Table2 as 
  select  subproduct,
          travel_year,
          travel_month,
          brx_anclry_rev_vlu
  from    homedir.anc_flown_all
  where   travel_year=&amp;amp;year.
    and   travel_month=&amp;amp;month.;
quit;&lt;BR /&gt;&lt;BR /&gt;%mend monmac;&lt;BR /&gt;&lt;BR /&gt;%monmac (tablename=forecast1,month=%str(month(intnx('months',today(),0))),year=%str(year(intnx('year',today(),0))));&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Although I can't see why you would want to do all that in the first place as the macro part adds nothing to the code at all, you can re-write like this, which is far simpler:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let inc=0;&lt;BR /&gt;&lt;BR /&gt;proc sql;
  create table homedir.Table2 as 
  select  subproduct,
          travel_year,
          travel_month,
          brx_anclry_rev_vlu
  from    homedir.anc_flown_all
  where   travel_year=intnx('year',today(),&amp;amp;inc.)
    and   travel_month=intnx('month',today(),&amp;amp;inc.);
quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Mar 2018 14:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444113#M282910</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-09T14:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: "Extract From date" Breaking my Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444124#M282911</link>
      <description>&lt;P&gt;What did you think this expression was going to do?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;EXTRACT(MONTH FROM ADD_MONTHS(CURRENT_DATE,0))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Looks like you might have meant to code something like this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MONTH(CURRENT_DATE)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or possibly&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MONTH(datepart(CURRENT_DATE))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Mar 2018 14:33:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444124#M282911</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-03-09T14:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: "Extract From date" Breaking my Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444130#M282912</link>
      <description>&lt;P&gt;Hi thanks for replying i got the Extract from terdata which is where i coded the SQL, so is the problem that I am using TERADATA functions in SAS?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 14:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444130#M282912</guid>
      <dc:creator>lloydsanford</dc:creator>
      <dc:date>2018-03-09T14:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: "Extract From date" Breaking my Macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444140#M282913</link>
      <description>&lt;P&gt;Thanks tom i see the error I made I was using Teradata syntax in SAS thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 14:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-Extract-From-date-quot-Breaking-my-Macro-variable/m-p/444140#M282913</guid>
      <dc:creator>lloydsanford</dc:creator>
      <dc:date>2018-03-09T14:42:54Z</dc:date>
    </item>
  </channel>
</rss>

