<?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: How to stop SAS not to Execute any further statements within %macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480084#M124036</link>
    <description>&lt;P&gt;All of WHAT values? Your example code is just putting ONE value into the macro variable.&lt;/P&gt;
&lt;P&gt;Are you asking how to use use the MAX() aggregate function in PROC SQL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to know what the %RETURN macro statement does you can look at the documentation.&lt;/P&gt;
&lt;P&gt;Or just make a test and run it.&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro xx;
%put BEFORE LOOP;
%do i=1 %to 10 ;
  %put &amp;amp;=i;
  %if &amp;amp;i &amp;gt;= 4 %then %return;
%end;
%put AFTER LOOP;
%mend xx;
%xx;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Jul 2018 22:17:37 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-07-20T22:17:37Z</dc:date>
    <item>
      <title>How to stop SAS not to Execute any further statements within %macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/479997#M124005</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
select count(distinct REPORT_ID) into :REPORT_ID_Count TRIMMED from REPORTS;
select distinct REPORT_ID into :REPORT_IDVal1- :REPORT_IDVal&amp;amp;REPORT_ID_Count from REPORTS;
quit;


%macro EACH_REPORT;
%do index = 1 %to &amp;amp;REPORT_ID_Count;

/*BUNCH OF PROC SQL STATEMENTS AND DATA STEPS*/
PROC SQL NOPRINT;&lt;BR /&gt;SELECT ADJUSTED_SCORE &lt;BR /&gt;INTO :ADJ_SCORE &lt;BR /&gt;FROM Final_Match ;&lt;BR /&gt;QUIT;&lt;BR /&gt;&lt;BR /&gt;/*If all  adjusted_SCORES are greater than 100 then end here go to the next report*/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/*BUNCH OF PROC SQL */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%EACH_REPORT&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am repeating a set of statements within a macro for each report_id. But I want to end the step if&amp;nbsp;all&amp;nbsp;adjusted scores are&amp;nbsp;greater&amp;nbsp;than 100 and go the next report _id. How do I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;using sas&amp;nbsp;EG 7.12&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 17:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/479997#M124005</guid>
      <dc:creator>Vk_2</dc:creator>
      <dc:date>2018-07-21T17:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop SAS not to Execute any further statements within %macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480008#M124007</link>
      <description>&lt;P&gt;Use %RETURN to end the execution of macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%IF Score&amp;gt;100 %THEN %RETURN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 18:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480008#M124007</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-07-20T18:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop SAS not to Execute any further statements within %macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480074#M124032</link>
      <description>&lt;P&gt;My adjusted score values might be more than one sometimes.&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT;SELECT ADJ_SCORE INTO :ADJ_SCORE FROM Final_Match ;QUIT;&lt;BR /&gt;%put macro variable ADJ_SCORE:&amp;amp;ADJ_SCORE;&lt;BR /&gt;so how do I test if all the values are greater than 100?&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrostatement"&gt;%IF&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;Score&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;100&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%THEN&lt;/SPAN&gt; &lt;SPAN class="token macroname"&gt;%RETURN&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and using the above statement, will it go the next iteration of report_id?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 21:30:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480074#M124032</guid>
      <dc:creator>Vk_2</dc:creator>
      <dc:date>2018-07-20T21:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop SAS not to Execute any further statements within %macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480084#M124036</link>
      <description>&lt;P&gt;All of WHAT values? Your example code is just putting ONE value into the macro variable.&lt;/P&gt;
&lt;P&gt;Are you asking how to use use the MAX() aggregate function in PROC SQL?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to know what the %RETURN macro statement does you can look at the documentation.&lt;/P&gt;
&lt;P&gt;Or just make a test and run it.&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro xx;
%put BEFORE LOOP;
%do i=1 %to 10 ;
  %put &amp;amp;=i;
  %if &amp;amp;i &amp;gt;= 4 %then %return;
%end;
%put AFTER LOOP;
%mend xx;
%xx;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 22:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480084#M124036</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-20T22:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop SAS not to Execute any further statements within %macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480159#M124068</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL NOPRINT;SELECT MIN(ADJUSTED_Score)as ADJ_SCORE INTO :ADJ_SCORE FROM Final_Match ;QUIT;
%put macro variable ADJ_SCORE:&amp;amp;ADJ_SCORE;
%if &amp;amp;ADJ_SCORE &amp;gt;= 100 %then %return;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is what I did. For the first Report_id it performed but for next REPORT_id it gave error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;macro variable ADJ_SCORE:-93.3333&lt;/P&gt;&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:&lt;BR /&gt;&amp;amp;ADJ_SCORE &amp;gt;= 100&lt;BR /&gt;ERROR: The macro EACH_REPORT will stop executing.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 16:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480159#M124068</guid>
      <dc:creator>Vk_2</dc:creator>
      <dc:date>2018-07-21T16:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop SAS not to Execute any further statements within %macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480161#M124069</link>
      <description>&lt;P&gt;If you want to use non-integer arithmetic in macro code you need to explicitly use %SYSEVALF(). Otherwise SAS will use %EVAL() which can only do integer arithmetic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf( &amp;amp;ADJ_SCORE &amp;gt;= 100.0) %then %return;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Jul 2018 16:31:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480161#M124069</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-21T16:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop SAS not to Execute any further statements within %macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480168#M124072</link>
      <description>&lt;P&gt;This corrected the previous error but what I realised is that it is terminating the macro but I want it to go to the next report_ID. So I did %end instead of %return&amp;nbsp; but it complaints&amp;nbsp; at&amp;nbsp;the next %END in the macro&lt;/P&gt;&lt;P&gt;ERROR: There is no matching %DO statement for the %END. This statement will be ignored.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Jul 2018 17:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480168#M124072</guid>
      <dc:creator>Vk_2</dc:creator>
      <dc:date>2018-07-21T17:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop SAS not to Execute any further statements within %macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480170#M124074</link>
      <description>&lt;P&gt;Please just post a simple example of the type of flow control you want to create.&lt;/P&gt;
&lt;P&gt;There is no %LEAVE or %CONTINUE statement in macro code. And unlike the data step DO the macro %DO does not allow multiple clauses so you can't create the equivalent of the data step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to 10 while (condition) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So just roll your own flow control by using labels and %GOTO statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put BEFORE DO loop;
%do i=1 %to 10 ;
...
%if %sysevalf(&amp;amp;x &amp;gt; 100) %then %goto after_loop ;
....
%end;
after_loop:
%put AFTER DO loop;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Jul 2018 18:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-stop-SAS-not-to-Execute-any-further-statements-within/m-p/480170#M124074</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-21T18:00:17Z</dc:date>
    </item>
  </channel>
</rss>

