<?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: statement between inner and outer do loop in nested do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/statement-between-inner-and-outer-do-loop-in-nested-do-loop/m-p/256915#M49289</link>
    <description>&lt;P&gt;The difference would be when to you want to change a value or perform an action.&lt;/P&gt;
&lt;P&gt;If you want to execute it before the J loop, then the first. If you want to change the value or do the action&amp;nbsp;each time then inside the inner loop. Your example doesn't really show much difference. But look at this difference:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
	put _all_;
        a=0;
	do i= 1 to 2;
		a=  a + 1;

		do j=1 to 3;
			put _all_;
			output;
		end;
	end;
run;

data test2;
	put _all_;
        a=0;
	do i= 1 to 2;
		do j=1 to 3;
			a= a + 1;
			put _all_;
			output;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You may want to do something only after the the inner loop has completed, in which case it would go after the inner loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2016 21:21:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-03-15T21:21:30Z</dc:date>
    <item>
      <title>statement between inner and outer do loop in nested do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/statement-between-inner-and-outer-do-loop-in-nested-do-loop/m-p/256912#M49288</link>
      <description>&lt;P&gt;How does the statement between inner and outer do loop execute? Under which conditions is it necessary to put statement &amp;nbsp;between inner and outer loop?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test1;
	put _all_;

	do i= 1 to 2;
		a=10;

		do j=1 to 3;
			put _all_;
			output;
		end;
	end;
run;

data test2;
	put _all_;

	do i= 1 to 2;
		do j=1 to 3;
			a=10;
			put _all_;
			output;
		end;
	end;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2016 21:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/statement-between-inner-and-outer-do-loop-in-nested-do-loop/m-p/256912#M49288</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-15T21:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: statement between inner and outer do loop in nested do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/statement-between-inner-and-outer-do-loop-in-nested-do-loop/m-p/256915#M49289</link>
      <description>&lt;P&gt;The difference would be when to you want to change a value or perform an action.&lt;/P&gt;
&lt;P&gt;If you want to execute it before the J loop, then the first. If you want to change the value or do the action&amp;nbsp;each time then inside the inner loop. Your example doesn't really show much difference. But look at this difference:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
	put _all_;
        a=0;
	do i= 1 to 2;
		a=  a + 1;

		do j=1 to 3;
			put _all_;
			output;
		end;
	end;
run;

data test2;
	put _all_;
        a=0;
	do i= 1 to 2;
		do j=1 to 3;
			a= a + 1;
			put _all_;
			output;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You may want to do something only after the the inner loop has completed, in which case it would go after the inner loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2016 21:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/statement-between-inner-and-outer-do-loop-in-nested-do-loop/m-p/256915#M49289</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-03-15T21:21:30Z</dc:date>
    </item>
  </channel>
</rss>

