<?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: macro syntax error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508370#M136534</link>
    <description>&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and adding&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no need to get human-readable dates into the macro variable. You are trying to do a lot of work to create human readable macro variables, with values like '09AUG18'd, when in fact you only need the actual SAS date value, which is 21405 in this case. This is so much easier programming than formatting&amp;nbsp;the values as you are trying to do.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Oct 2018 15:07:26 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-10-29T15:07:26Z</dc:date>
    <item>
      <title>macro syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508362#M136528</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to assign to first and last date as macro. my code is below but give me syntax error. How can I correct this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="dgrid-header dgrid-header-row ui-widget-header"&gt;n&amp;nbsp; &amp;nbsp; date&lt;BR /&gt;&lt;DIV class="dgrid-resize-handle resizeNode-1"&gt;1 31AUG2018&amp;nbsp;---last date&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;&lt;DIV class="dgrid-content ui-widget-content"&gt;&lt;DIV class=" dgrid-row ui-state-default dgrid-row-even"&gt;&lt;P&gt;2 30JUN2018&lt;BR /&gt;3 31MAR2018&lt;BR /&gt;4 31DEC2017&lt;BR /&gt;5 30SEP2017&lt;BR /&gt;6 30JUN2017&lt;BR /&gt;7 31MAR2017--first date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="dgrid-scroller"&gt;&lt;DIV class="dgrid-content ui-widget-content"&gt;&lt;DIV class=" dgrid-row ui-state-default dgrid-row-even"&gt;&lt;P&gt;proc sql noprint;/*assign macro variable as_of_date*/&lt;BR /&gt;select catx('', quote(put(date, date9.)), 'd'),catx('', quote(put(date, date9.)), 'd'),n&lt;BR /&gt;into :dates1-,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :as_of_date separated by ','&lt;BR /&gt;from z;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let as_of_date=(&amp;amp;as_of_date);&lt;BR /&gt;%let date_last=%qscan(&amp;amp;as_of_date,1);&lt;BR /&gt;%let date_first=%qscan(&amp;amp;as_of_date,-1);&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;73 proc sql;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;73 ! create table Sandbox.hh_new as&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 select ASOFDATE,HHNUM,NEWHH,RETURNHH,STARTDATE&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 from tlake.mkt_hhsumm&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 where ASOFDATE between &amp;amp;date_first and &amp;amp;date_last /*dates1 and dateslast*/&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: Line generated by the macro variable "DATE_FIRST".&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 "30JUN2017"d&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_&lt;/DIV&gt;&lt;DIV class="sasError"&gt;76&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;a missing value, (, +, -, BTRIM, CALCULATED, CASE, INPUT, PUT, SUBSTRING, TRANSLATE, USER.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77 and HHNUM ne 0&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 and (NEWHH=1 or RETURNHH=1);&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;79 quit;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&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;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 29 Oct 2018 14:55:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508362#M136528</guid>
      <dc:creator>jojozheng</dc:creator>
      <dc:date>2018-10-29T14:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: macro syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508366#M136532</link>
      <description>&lt;P&gt;A simple data step with call symputx will do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data z;
input n date :date9.;
format date date9.;
cards;
1 31AUG2018
2 30JUN2018
3 31MAR2018
4 31DEC2017
5 30SEP2017
6 30JUN2017
7 31MAR2017
;
run;

data _null_;
set z end=eof;
if _n_ = 1 then call symputx('date_last',date);
if eof then call symputx('date_first',date);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The raw values will work in your SQL condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as
select * from z
where date between &amp;amp;date_first. and &amp;amp;date_last.;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Oct 2018 15:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508366#M136532</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-29T15:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: macro syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508368#M136533</link>
      <description>&lt;P&gt;PS when posting SAS (or other) logs, always use the {i} button to preserve the formatting.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 15:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508368#M136533</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-29T15:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: macro syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508370#M136534</link>
      <description>&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and adding&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no need to get human-readable dates into the macro variable. You are trying to do a lot of work to create human readable macro variables, with values like '09AUG18'd, when in fact you only need the actual SAS date value, which is 21405 in this case. This is so much easier programming than formatting&amp;nbsp;the values as you are trying to do.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 15:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508370#M136534</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-10-29T15:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: macro syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508373#M136536</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;and adding&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's no need to get human-readable dates into the macro variable. You are trying to do a lot of work to create human readable macro variables, with values like '09AUG18'd, when in fact you only need the actual SAS date value, which is 21405 in this case. This is so much easier programming than formatting&amp;nbsp;the values as you are trying to do.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Also known as Maxim 28 &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Oct 2018 15:08:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508373#M136536</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-29T15:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: macro syntax error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508383#M136540</link>
      <description>&lt;P&gt;You could skip sequential access with a direct access using point=&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data z;
input n date :date9.;
format date date9.;
cards;
1 31AUG2018
2 30JUN2018
3 31MAR2018
4 31DEC2017
5 30SEP2017
6 30JUN2017
7 31MAR2017
;
run;
data _null_;
do _n_=1,nobs;
set z nobs=nobs point=_n_;
call symputx(ifc(_n_=1,'date_last','date_first'),date);
end;
stop;
run;
%put &amp;amp;date_last   &amp;amp;date_first;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Oct 2018 15:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-syntax-error/m-p/508383#M136540</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-29T15:27:14Z</dc:date>
    </item>
  </channel>
</rss>

