<?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-if in stop statement of macro-do-loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-if-in-stop-statement-of-macro-do-loop/m-p/754550#M237973</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;ERROR: There is no matching %IF statement for the %ELSE.&lt;/PRE&gt;
&lt;P&gt;%IF is in a location in a %DO statement where it is not allowed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ERROR: A dummy macro will be compiled.&lt;/PRE&gt;
&lt;P&gt;You macro named %A has not been compiled and so cannot be used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This, however, would work, as now the %IF is in a position where it is recognized. (Your %b is another way to make this work)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro a(condition);
    %if &amp;amp;condition. %then %let endvalue = 2; 
    %else %let endvalue=3;
    %do i = 1 %to &amp;amp;endvalue;
        %put &amp;amp;i.;
    %end;
%mend;

%a(0)
%a(1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 16 Jul 2021 10:58:05 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-07-16T10:58:05Z</dc:date>
    <item>
      <title>macro-if in stop statement of macro-do-loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-if-in-stop-statement-of-macro-do-loop/m-p/754545#M237969</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro a(condition);
  %do i = 1 %to %if &amp;amp;condition. %then 2; %else 3;;
    %put &amp;amp;i.;
  %end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: There is no matching %IF statement for the %ELSE.
ERROR: A dummy macro will be compiled.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;what is the problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro b(condition);
  %do i = 1 %to %sysfunc(ifn(&amp;amp;condition., 2, 3));
    %put &amp;amp;i.;
  %end;
%mend;

%b(0);
%b(1);&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%b(0);
1
2
3
%b(1);
1
2&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;this seem to work, though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 10:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-if-in-stop-statement-of-macro-do-loop/m-p/754545#M237969</guid>
      <dc:creator>Quodly</dc:creator>
      <dc:date>2021-07-16T10:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: macro-if in stop statement of macro-do-loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-if-in-stop-statement-of-macro-do-loop/m-p/754550#M237973</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;ERROR: There is no matching %IF statement for the %ELSE.&lt;/PRE&gt;
&lt;P&gt;%IF is in a location in a %DO statement where it is not allowed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ERROR: A dummy macro will be compiled.&lt;/PRE&gt;
&lt;P&gt;You macro named %A has not been compiled and so cannot be used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This, however, would work, as now the %IF is in a position where it is recognized. (Your %b is another way to make this work)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro a(condition);
    %if &amp;amp;condition. %then %let endvalue = 2; 
    %else %let endvalue=3;
    %do i = 1 %to &amp;amp;endvalue;
        %put &amp;amp;i.;
    %end;
%mend;

%a(0)
%a(1)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Jul 2021 10:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-if-in-stop-statement-of-macro-do-loop/m-p/754550#M237973</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-16T10:58:05Z</dc:date>
    </item>
  </channel>
</rss>

