<?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 Do loop didn't work? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905706#M357699</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if If&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Two IFs in succession can't work.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Dec 2023 20:53:59 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-12-01T20:53:59Z</dc:date>
    <item>
      <title>Macro Do loop didn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905696#M357697</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;The sample macro do loop coding didn't work.&amp;nbsp; Please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let X1=21;
%let X2=22;
%let X3=23;

%Macro aaa (Pathogen);
	data Want;
		set Have;

	%do i  = 1 %to 3;
		If &amp;amp;&amp;amp;X&amp;amp;i..01 &amp;lt;=WeekCode&amp;lt;= &amp;amp;&amp;amp;X&amp;amp;i..13 then Quarter=1;
		else if If &amp;amp;&amp;amp;X&amp;amp;i..14 &amp;lt;=WeekCode&amp;lt;= &amp;amp;&amp;amp;X&amp;amp;i..26 then Quarter=2;
		else if If &amp;amp;&amp;amp;X&amp;amp;i..27 &amp;lt;=WeekCode&amp;lt;= &amp;amp;&amp;amp;X&amp;amp;i..39 then Quarter=3;
		else if If &amp;amp;&amp;amp;X&amp;amp;i..40 &amp;lt;=WeekCode&amp;lt;= &amp;amp;&amp;amp;X&amp;amp;i..52 then Quarter=4;
	%end;;

run;

%mend;
%aaa (RSV);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The error message was partially shown in the log window below.&lt;/P&gt;
&lt;PRE&gt;SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable X3 resolves to 23
MPRINT(AAA):   else if If 2327 &amp;lt;=WeekCode &amp;lt;= 2339 then Quarter=3;
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable X3 resolves to 23
NOTE: Line generated by the macro variable "X3".
1     2340
      ----
      22
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable X3 resolves to 23
MPRINT(AAA):   else if If 2340 &amp;lt;=WeekCode &amp;lt;= 2352 then Quarter=4;
MLOGIC(AAA):  %DO loop index variable I is now 4; loop will not iterate again.
MPRINT(AAA):  ;
MPRINT(AAA):   run;

ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;,
              =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, LE, LT, MAX, MIN, NE, NG, NL, OR, [, ^=, {, |, ||,
              ~=.

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.RSV may be incomplete.  When this step was stopped there were 0
         observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.99 seconds
      cpu time            0.06 seconds
&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2023 20:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905696#M357697</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2023-12-01T20:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Do loop didn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905706#M357699</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if If&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Two IFs in succession can't work.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 20:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905706#M357699</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-12-01T20:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Do loop didn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905707#M357700</link>
      <description>&lt;PRE&gt;		else if If &amp;amp;&amp;amp;X&amp;amp;i..14 &amp;lt;=WeekCode&amp;lt;= &amp;amp;&amp;amp;X&amp;amp;i..26 then Quarter=2;
		else if If &amp;amp;&amp;amp;X&amp;amp;i..27 &amp;lt;=WeekCode&amp;lt;= &amp;amp;&amp;amp;X&amp;amp;i..39 then Quarter=3;
		else if If &amp;amp;&amp;amp;X&amp;amp;i..40 &amp;lt;=WeekCode&amp;lt;= &amp;amp;&amp;amp;X&amp;amp;i..52 then Quarter=4;
&lt;/PRE&gt;
&lt;P&gt;else if if.. Could you try to remove one of IF's?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 20:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905707#M357700</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-12-01T20:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Do loop didn't work?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905717#M357702</link>
      <description>&lt;P&gt;If instead of something odd like "weekcode" you had an actual DATE value then the QTR function would return the value from the date and this macro wouldn't be needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or whatever need is served by this 'quarter' (and week) value could likely be accomplished with a proper format in analysis or reporting.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 21:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Do-loop-didn-t-work/m-p/905717#M357702</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-12-01T21:15:23Z</dc:date>
    </item>
  </channel>
</rss>

