<?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 do loop in macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-loop-in-macro/m-p/342828#M78618</link>
    <description>&lt;P&gt;I'm studing how to&amp;nbsp;use Macro in sas and learn coding from other people.&lt;/P&gt;
&lt;P&gt;I have a question about the do loop for this code I wonder why they need to put loop j=1 to ... because in loop they didn't refer to j .&lt;/P&gt;
&lt;P&gt;Anyone could help please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;Component_List,'/'));
&amp;nbsp;&amp;nbsp;&amp;nbsp;if pay_cd in ( %do j=1 %to %sysfunc(countw(&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;Component_List_Name_&amp;amp;i,'/'));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;     %sysfunc(catq('1a',%sysfunc(translate(&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;Component_List_Name_&amp;amp;i,%str(,),%str( )))))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end; )
then Component_1 = "%scan(&amp;amp;Component_List,&amp;amp;i,'/')";
%end;
&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Mar 2017 03:49:59 GMT</pubDate>
    <dc:creator>Smile_</dc:creator>
    <dc:date>2017-03-21T03:49:59Z</dc:date>
    <item>
      <title>do loop in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-in-macro/m-p/342828#M78618</link>
      <description>&lt;P&gt;I'm studing how to&amp;nbsp;use Macro in sas and learn coding from other people.&lt;/P&gt;
&lt;P&gt;I have a question about the do loop for this code I wonder why they need to put loop j=1 to ... because in loop they didn't refer to j .&lt;/P&gt;
&lt;P&gt;Anyone could help please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;Component_List,'/'));
&amp;nbsp;&amp;nbsp;&amp;nbsp;if pay_cd in ( %do j=1 %to %sysfunc(countw(&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;Component_List_Name_&amp;amp;i,'/'));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;     %sysfunc(catq('1a',%sysfunc(translate(&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;Component_List_Name_&amp;amp;i,%str(,),%str( )))))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end; )
then Component_1 = "%scan(&amp;amp;Component_List,&amp;amp;i,'/')";
%end;
&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 03:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-in-macro/m-p/342828#M78618</guid>
      <dc:creator>Smile_</dc:creator>
      <dc:date>2017-03-21T03:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: do loop in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-in-macro/m-p/342839#M78622</link>
      <description>&lt;P&gt;You should probably study a different program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can post an example of the values of the miriad macro variables that this program is referencing then perhaps we can make sense of it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that originally the program looped over the values and then they changed the logic to try to take advantage of the CATQ() function and forgot to remove the loop. &amp;nbsp;Since generating&amp;nbsp;duplicate lists of codes like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if pay_cd in ( 'A' 'B' 'C' 'A' 'B' 'C' 'A' 'B' 'C') then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;instead of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if pay_cd in ( 'A' 'B' 'C' ) then ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;wouldn't actually make the program fail or even change the result they probably never noticed the mistake.&lt;/P&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;</description>
      <pubDate>Tue, 21 Mar 2017 04:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-in-macro/m-p/342839#M78622</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-21T04:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: do loop in macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-loop-in-macro/m-p/342861#M78628</link>
      <description>&lt;P&gt;Dear Tom ,Thank you so much.&amp;nbsp; very understand &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2017 07:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-loop-in-macro/m-p/342861#M78628</guid>
      <dc:creator>Smile_</dc:creator>
      <dc:date>2017-03-21T07:16:49Z</dc:date>
    </item>
  </channel>
</rss>

