<?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: %Do %while loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432163#M106993</link>
    <description>&lt;P&gt;That's a simple fomula:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;endvalue = startvalue * 2 ** 100000;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will, of course, exceed any displayable value. Think of the wise guy demanding rice from the king. 1 grain on the first square of the chess-board, and double on every further square.&lt;/P&gt;
&lt;P&gt;Now, if you want to find the iteration where the result exceeds 100000, you need this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
value = 1;
iteration = 1;
do until (value &amp;gt; 100000);
  output;
  value = value * 2;
  iteration + 1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 30 Jan 2018 12:44:42 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-01-30T12:44:42Z</dc:date>
    <item>
      <title>%Do %while loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432152#M106988</link>
      <description>&lt;P&gt;HI i am trying to write a code to calculate the below scenario ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;lets say i started investing with Rs1 , and i will double the money every day , i.e&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st day=Rs1&lt;/P&gt;&lt;P&gt;2nd day = Rs2&lt;/P&gt;&lt;P&gt;3rd day = Rs4&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;so on..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to know how many days it will take to make my investment in to Rs100000&lt;/P&gt;&lt;P&gt;i am trying the below code but some how not getting the logic to do so , please help...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA investthree;&lt;BR /&gt;DO until (value &amp;gt;= 100000);&lt;BR /&gt;value+1;&lt;BR /&gt;_value=value*2;&lt;BR /&gt;&lt;BR /&gt;day + 1;&lt;BR /&gt;OUTPUT;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2018 12:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432152#M106988</guid>
      <dc:creator>soham_sas</dc:creator>
      <dc:date>2018-01-30T12:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: %Do %while loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432162#M106992</link>
      <description>&lt;P&gt;Your loop won't resolve.&amp;nbsp; The below outputs what I think you are looking for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
	value = 1;
	days = 1;
	do while (value lt 100000);
		value = value*2;
		put 'NOTE: ' days ': ' value;
		days = days+1;
	end;
	output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jan 2018 12:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432162#M106992</guid>
      <dc:creator>foobarbaz</dc:creator>
      <dc:date>2018-01-30T12:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: %Do %while loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432163#M106993</link>
      <description>&lt;P&gt;That's a simple fomula:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;endvalue = startvalue * 2 ** 100000;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which will, of course, exceed any displayable value. Think of the wise guy demanding rice from the king. 1 grain on the first square of the chess-board, and double on every further square.&lt;/P&gt;
&lt;P&gt;Now, if you want to find the iteration where the result exceeds 100000, you need this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
value = 1;
iteration = 1;
do until (value &amp;gt; 100000);
  output;
  value = value * 2;
  iteration + 1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jan 2018 12:44:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432163#M106993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-01-30T12:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: %Do %while loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432216#M107018</link>
      <description>&lt;P&gt;So your question does not match your subject line. You appear to be trying to use a data step DO statement instead of a macro %DO statement.&amp;nbsp; That will actually make it easier to do what you want since the DO statement is much more powerful than the %DO statement.&lt;/P&gt;
&lt;PRE&gt;664   data investthree;
665     do day=1 by 1 until (value &amp;gt;= 100000);
666       if day=1 then value=1;
667       else value=value*2 ;
668       put day=z4. +1 value= comma10.;
669       output;
670     end;
671   run;

day=0001  value=1
day=0002  value=2
day=0003  value=4
day=0004  value=8
day=0005  value=16
day=0006  value=32
day=0007  value=64
day=0008  value=128
day=0009  value=256
day=0010  value=512
day=0011  value=1,024
day=0012  value=2,048
day=0013  value=4,096
day=0014  value=8,192
day=0015  value=16,384
day=0016  value=32,768
day=0017  value=65,536
day=0018  value=131,072
NOTE: The data set WORK.INVESTTHREE has 18 observations and 2 variables.
&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Jan 2018 14:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-while-loop/m-p/432216#M107018</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-01-30T14:43:20Z</dc:date>
    </item>
  </channel>
</rss>

