<?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: Creating a new data set using DO loop from another data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319458#M70169</link>
    <description>&lt;P&gt;A data step has an implicit output; at the end of the step, if no explicit output; has been coded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your data step reads three observations from banks, and so reaches the end-of-file condition. After the do loop, the data step reaches the end of its first iteration, writes one observation (no output present in the do loop!), recognizes the EOF, and terminates.&lt;/P&gt;
&lt;P&gt;newbank will have the last observation of bank, with year = 4 and capital = 15000 added.&lt;/P&gt;
&lt;P&gt;year will be 4 because of the way a do loop with an iteration variable is executed.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Dec 2016 07:16:26 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-12-16T07:16:26Z</dc:date>
    <item>
      <title>Creating a new data set using DO loop from another data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319455#M70168</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The SAS data set BANKS is listed below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;U&gt;name rate&lt;/U&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;BR /&gt;&lt;/U&gt;&lt;SPAN&gt;FirstCapital 0.0718&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DirectBank 0.0721&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;VirtualDirect 0.0728&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The following SAS program is submitted:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data newbank;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;do year = 1 to 3;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set banks;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; capital + 5000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Which one of the following represents how many observations and variables will exist in the SAS data set NEWBANK?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A. 0 observations and 0 variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;B. 1 observations and 4 variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C. 3 observations and 3 variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;D. 9 observations and 2 variables&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;-&amp;gt; The answer for above question is (B). Could anyone please explain how it is being processed to get only 1 observation in final output ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 07:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319455#M70168</guid>
      <dc:creator>PoojaP1</dc:creator>
      <dc:date>2016-12-16T07:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new data set using DO loop from another data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319458#M70169</link>
      <description>&lt;P&gt;A data step has an implicit output; at the end of the step, if no explicit output; has been coded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your data step reads three observations from banks, and so reaches the end-of-file condition. After the do loop, the data step reaches the end of its first iteration, writes one observation (no output present in the do loop!), recognizes the EOF, and terminates.&lt;/P&gt;
&lt;P&gt;newbank will have the last observation of bank, with year = 4 and capital = 15000 added.&lt;/P&gt;
&lt;P&gt;year will be 4 because of the way a do loop with an iteration variable is executed.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 07:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319458#M70169</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-16T07:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new data set using DO loop from another data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319466#M70173</link>
      <description>&lt;P&gt;"B" is correct, but the process is a little more complex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step leaves the DATA statement to execute the remaining programming statements. &amp;nbsp;As part of that process, it executes the DO loop (which includes executing the SET statement 3 times and reading all 3 observations from BANKS). &amp;nbsp;At the bottom of the DATA step, it outputs the one observation and returns to the DATA statement. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step leaves the DATA statement a second time, and starts executing the remaining statements within the DATA step. &amp;nbsp;It starts the DO loop, and attempts to execute the SET statement for the fourth time. &amp;nbsp;SInce&amp;nbsp;there is no fourth observation to be read, the DATA step ends at that point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can help illustrate the process by adding this statement immediately following the DO statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;put _n_= year=;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can add to the PUT statement, and add other PUT statements as well to help illustrate the process.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 08:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319466#M70173</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-12-16T08:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new data set using DO loop from another data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319473#M70176</link>
      <description>&lt;P&gt;Just to add, the data step written this way creates loop which gives you exact control over the lines of the data set banks, in addition it does not output at the end of each step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can imagine that the looping variable year corresponds to the line number of the data set. It goes over all 3 lines and outputs outside the loop when it reaches the run statement in the data step(implicit output).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The more accurate explanations are the preceeding ones &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; but this could help you to understand...&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2016 08:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/319473#M70176</guid>
      <dc:creator>chrej5am</dc:creator>
      <dc:date>2016-12-16T08:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a new data set using DO loop from another data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/320103#M70444</link>
      <description>Thank you everyone for the explanations! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 20 Dec 2016 06:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-new-data-set-using-DO-loop-from-another-data-set/m-p/320103#M70444</guid>
      <dc:creator>PoojaP1</dc:creator>
      <dc:date>2016-12-20T06:17:19Z</dc:date>
    </item>
  </channel>
</rss>

