<?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 When can I use Do loop with % sign in Macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/When-can-I-use-Do-loop-with-sign-in-Macro/m-p/538183#M6899</link>
    <description>&lt;P&gt;Hi everyone! I am learning to use macro in SAS and I have got a question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my understanding, we have to use %DO to let SAS to know we are using do statement. However, I found that the script is still working when do (without % sign) is used in nested do loop. Is that mean % sign is not necessary to be used for nested do loop in macro? Many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Script:&lt;/P&gt;&lt;P&gt;%macro mymacro;&lt;/P&gt;&lt;P&gt;%let i=0;&lt;/P&gt;&lt;P&gt;%let j=0;&lt;/P&gt;&lt;P&gt;%do %until(&amp;amp;i&amp;gt;5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do until(&amp;amp;j&amp;gt;5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %let product=%sysevalf(&amp;amp;i*&amp;amp;j);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %put The result is &amp;amp;product;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;%let j=%eval(&amp;amp;j+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %let i=%eval(&amp;amp;i+1);&lt;/P&gt;&lt;P&gt;%mend&lt;/P&gt;</description>
    <pubDate>Mon, 25 Feb 2019 04:51:32 GMT</pubDate>
    <dc:creator>sky_sas</dc:creator>
    <dc:date>2019-02-25T04:51:32Z</dc:date>
    <item>
      <title>When can I use Do loop with % sign in Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/When-can-I-use-Do-loop-with-sign-in-Macro/m-p/538183#M6899</link>
      <description>&lt;P&gt;Hi everyone! I am learning to use macro in SAS and I have got a question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my understanding, we have to use %DO to let SAS to know we are using do statement. However, I found that the script is still working when do (without % sign) is used in nested do loop. Is that mean % sign is not necessary to be used for nested do loop in macro? Many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Script:&lt;/P&gt;&lt;P&gt;%macro mymacro;&lt;/P&gt;&lt;P&gt;%let i=0;&lt;/P&gt;&lt;P&gt;%let j=0;&lt;/P&gt;&lt;P&gt;%do %until(&amp;amp;i&amp;gt;5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; do until(&amp;amp;j&amp;gt;5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %let product=%sysevalf(&amp;amp;i*&amp;amp;j);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %put The result is &amp;amp;product;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;%let j=%eval(&amp;amp;j+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %let i=%eval(&amp;amp;i+1);&lt;/P&gt;&lt;P&gt;%mend&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 04:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/When-can-I-use-Do-loop-with-sign-in-Macro/m-p/538183#M6899</guid>
      <dc:creator>sky_sas</dc:creator>
      <dc:date>2019-02-25T04:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: When can I use Do loop with % sign in Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/When-can-I-use-Do-loop-with-sign-in-Macro/m-p/538185#M6900</link>
      <description>The answer is more complex than you are ready to digest at this point.  Add this statement first:&lt;BR /&gt;&lt;BR /&gt;Options mprint symbolgen;&lt;BR /&gt;&lt;BR /&gt;Then rerun the program and read the log.</description>
      <pubDate>Mon, 25 Feb 2019 05:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/When-can-I-use-Do-loop-with-sign-in-Macro/m-p/538185#M6900</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-25T05:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: When can I use Do loop with % sign in Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/When-can-I-use-Do-loop-with-sign-in-Macro/m-p/538187#M6901</link>
      <description>&lt;P&gt;The Correct code is bellow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro;
	%let i=0;
	%let j=0;
	%do %until(&amp;amp;i&amp;gt;5);
		%do %until(&amp;amp;j&amp;gt;5);
			%let product=%sysevalf(&amp;amp;i*&amp;amp;j);
			%put The result is &amp;amp;product;
			%let j=%eval(&amp;amp;j+1);
		%end;
		%let i=%eval(&amp;amp;i+1);
	%end;
%mend;
%mymacro;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The Macro compiler is called by a word processor in SAS.&lt;/P&gt;&lt;P&gt;When you wrote a do in side a %do, SAS assumed that the do is a part of some other sas statement which will be used after the macro processing. That you can see if you try to execute the macro. You will get the following error.&lt;/P&gt;&lt;PRE&gt;NOTE: Line generated by the invoked macro "MYMACRO".
 85          do until(&amp;amp;j&amp;gt;5);
             __
             180
 
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 
 The result is 0
 NOTE: Line generated by the invoked macro "MYMACRO".
 85            end;
               ___
               180
 
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 
 NOTE: Line generated by the invoked macro "MYMACRO".
 85            do until(&amp;amp;j&amp;gt;5);
               __
               180
 
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 
 The result is 1
 NOTE: Line generated by the invoked macro "MYMACRO".
 85            end;
               ___
               180
 
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 
 NOTE: Line generated by the invoked macro "MYMACRO".
 85            do until(&amp;amp;j&amp;gt;5);
               __
               180
 
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 
 The result is 4
.
.
.&lt;/PRE&gt;&lt;P&gt;Macro is a very powerfull lnguage which can be mixed with BASE SAS to get results, but macro can not be mixed with BASE SAS utilities alone.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 05:28:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/When-can-I-use-Do-loop-with-sign-in-Macro/m-p/538187#M6901</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2019-02-25T05:28:37Z</dc:date>
    </item>
  </channel>
</rss>

