<?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 why does do while retain values from if then. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396765#M95829</link>
    <description>&lt;P&gt;Can anybody give me the explanation to why the values nn2 and n3 are retained in this do while statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test;
n=0;
   do while(n&amp;lt;5);
      put n=;
      n+1;
	  if n=1 then n2=1;
	  if n=2 then n3=2;
	  output;
	end;
run;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Udklip.PNG" style="width: 322px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15239i609A20E36A75D599/image-size/large?v=v2&amp;amp;px=999" role="button" title="Udklip.PNG" alt="Udklip.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Sep 2017 11:14:14 GMT</pubDate>
    <dc:creator>rudfaden</dc:creator>
    <dc:date>2017-09-18T11:14:14Z</dc:date>
    <item>
      <title>why does do while retain values from if then.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396765#M95829</link>
      <description>&lt;P&gt;Can anybody give me the explanation to why the values nn2 and n3 are retained in this do while statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test;
n=0;
   do while(n&amp;lt;5);
      put n=;
      n+1;
	  if n=1 then n2=1;
	  if n=2 then n3=2;
	  output;
	end;
run;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Udklip.PNG" style="width: 322px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15239i609A20E36A75D599/image-size/large?v=v2&amp;amp;px=999" role="button" title="Udklip.PNG" alt="Udklip.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 11:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396765#M95829</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2017-09-18T11:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: why does do while retain values from if then.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396777#M95830</link>
      <description>&lt;P&gt;You have a one pass data step. &amp;nbsp;It never goes back for a second pass becasue there is not input data set. &amp;nbsp;Nothing is retained (in the normal SAS sense). &amp;nbsp;Nothing is reinitialized to missing for the second pass, because there is no second pass.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 12:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396777#M95830</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-09-18T12:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: why does do while retain values from if then.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396778#M95831</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PDV, that is, the vector holding values for the currently processed observation is only cleared&lt;/P&gt;
&lt;P&gt;when the interpreter meets the run instruction. Here, you are always processing the same observation that&lt;/P&gt;
&lt;P&gt;you modify and output several times. There is no reason for the values of n2 and n3 to be reset.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 12:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396778#M95831</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-09-18T12:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: why does do while retain values from if then.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396780#M95832</link>
      <description>&lt;P&gt;Are you saying it is because sas keeps n2 and n3 in memory and then keeps priting the same values?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2017 12:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396780#M95832</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2017-09-18T12:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: why does do while retain values from if then.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396888#M95872</link>
      <description>&lt;P&gt;Maybe this adds a bit to what goes on:&lt;/P&gt;
&lt;PRE&gt;data test;
n=0;
   do while(n&amp;lt;5);
      put n=;
      n+1;
	  if n=1 then n2=1;
          else n2=.;
	  if n=2 then n3=2;
          else n3=.;
	  output;
	end;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Sep 2017 17:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-does-do-while-retain-values-from-if-then/m-p/396888#M95872</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-18T17:34:02Z</dc:date>
    </item>
  </channel>
</rss>

