<?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 loop in data step in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416991#M26847</link>
    <description>&lt;P&gt;Not sure what all the while part is for in the first place, it is a simple loop with a by statement:&lt;/P&gt;
&lt;PRE&gt;data ids2;
  attrib id format=12.;
  do id=&amp;amp;min. to &amp;amp;max. by &amp;amp;min.;
    output;
  end;
run; &lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Nov 2017 09:19:04 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-29T09:19:04Z</dc:date>
    <item>
      <title>Do loop in data step</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416981#M26841</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is wrong with that script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%LET MIN=1;&lt;BR /&gt;%LET MAX=1000000;&lt;/P&gt;&lt;P&gt;;DATA IDS(KEEP=ID);&lt;BR /&gt;RETAIN I;&lt;BR /&gt;ATTRIB ID FORMAT=12.;&lt;BR /&gt;I=1;&lt;BR /&gt;MAX=&amp;amp;MAX.;&lt;BR /&gt;DO (WHILE ID&amp;lt;MAX);&lt;BR /&gt;ID=&amp;amp;MIN.*I;&lt;BR /&gt;OUTPUT;&lt;BR /&gt;I+1;&lt;BR /&gt;END;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 07:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416981#M26841</guid>
      <dc:creator>kanivan51</dc:creator>
      <dc:date>2017-11-29T07:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop in data step</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416982#M26842</link>
      <description>&lt;OL&gt;
&lt;LI&gt;You code all upcase.&lt;/LI&gt;
&lt;LI&gt;You didn't use the {i} or running-man-icon to post the code.&lt;/LI&gt;
&lt;LI&gt;I don't have a crystal ball showing the log output and/or what you expected.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 29 Nov 2017 07:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416982#M26842</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-11-29T07:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop in data step</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416984#M26843</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET MIN=1;
%LET MAX=1000000;

;DATA IDS(KEEP=ID);
RETAIN I;
ATTRIB ID FORMAT=12.;
I=1;
MAX=&amp;amp;MAX.;
DO (WHILE ID&amp;lt;MAX);
ID=&amp;amp;MIN.*I;
OUTPUT;
I+1;
END;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="err.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16900iC4DB696D10473873/image-size/large?v=v2&amp;amp;px=999" role="button" title="err.JPG" alt="err.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 08:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416984#M26843</guid>
      <dc:creator>kanivan51</dc:creator>
      <dc:date>2017-11-29T08:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop in data step</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416989#M26846</link>
      <description>&lt;P&gt;Maxim 2: Read the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You get this:&lt;/P&gt;
&lt;PRE&gt;1         MAX=&amp;amp;MAX.;
32         DO (WHILE ID&amp;lt;MAX);
                     __
                     22
ERROR: Undeclared array referenced: DO.
32         DO (WHILE ID&amp;lt;MAX);
                            _
                            22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, 
              GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, [, ^=, {, |, ||, ~=.  

ERROR 22-322: Syntax error, expecting one of the following: +, =.  

32         DO (WHILE ID&amp;lt;MAX);
                            _
                            76
ERROR 76-322: Syntax error, statement will be ignored.
&lt;/PRE&gt;
&lt;P&gt;which points to a problem with the way you wrote the do statement.&lt;/P&gt;
&lt;P&gt;Maxim 1: Read the documentation.&lt;/P&gt;
&lt;P&gt;The documentation for the &lt;A href="http://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.2&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p1awxgleif5wlen1pja0nrn6yi6i.htm&amp;amp;locale=en" target="_blank"&gt;do while statement&lt;/A&gt; reads:&lt;/P&gt;
&lt;H2 id="n09lbo5xpo7gfdn1315cm1rjn7q1" class="xis-title" style="box-sizing: border-box; font-family: AvenirNext, Helvetica, Arial, sans-serif; font-weight: bold; line-height: 1.1; color: #333333; margin-top: 0.5em; margin-bottom: 10px; font-size: 1.125rem; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial;"&gt;Syntax&lt;/H2&gt;
&lt;DIV class="xis-syntaxSimple" style="box-sizing: border-box; margin-top: 0.8em; display: block; overflow: auto; color: #333333; font-family: AvenirNext, Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial;"&gt;
&lt;DIV class="xis-syntaxLevel" style="box-sizing: border-box; margin-top: 0.6em; white-space: nowrap; display: block;"&gt;&lt;SPAN class="xis-keyword" style="box-sizing: border-box; font-weight: 600;"&gt;DO WHILE&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(&lt;SPAN class="xis-userSuppliedSyntaxValue" style="box-sizing: border-box; font-style: italic;"&gt;&lt;A class="ng-scope" style="box-sizing: border-box; background-color: transparent; color: #287eab; text-decoration: none;" tabindex="0" title="Description of syntax: (expression)" href="http://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.2&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p1awxgleif5wlen1pja0nrn6yi6i.htm&amp;amp;locale=de#p1vcidukuzk2l0n1e1eawxcauna6" rel="nofollow" data-docset-id="lestmtsref" data-docset-version="9.4" data-original-href="p1awxgleif5wlen1pja0nrn6yi6i.htm#p1vcidukuzk2l0n1e1eawxcauna6"&gt;expression&lt;/A&gt;&lt;/SPAN&gt;);&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;which means that the opening parenthesis must come &lt;EM&gt;after&lt;/EM&gt; the "while".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now look at this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let min=1;
%let max=1000000;

data ids(keep=id);
attrib id format=12.;
I = 1;
max = &amp;amp;max.;
do while (id &amp;lt; max);
  id = &amp;amp;min. * i;
  output;
  i + 1;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and tell us which code is easier to read and understand?&lt;/P&gt;
&lt;P&gt;Follow Maxim 12, and avoid coding in all-uppercase. The 1950's are long past.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW I removed the unnecessary retain statement. Read the &lt;A href="http://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.2&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p0t2ac0tfzcgbjn112mu96hkgg9o.htm&amp;amp;locale=en" target="_blank"&gt;documentation&lt;/A&gt; what it does and when it should be used.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 08:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416989#M26846</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-29T08:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop in data step</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416991#M26847</link>
      <description>&lt;P&gt;Not sure what all the while part is for in the first place, it is a simple loop with a by statement:&lt;/P&gt;
&lt;PRE&gt;data ids2;
  attrib id format=12.;
  do id=&amp;amp;min. to &amp;amp;max. by &amp;amp;min.;
    output;
  end;
run; &lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Nov 2017 09:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/416991#M26847</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-29T09:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop in data step</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/417114#M26851</link>
      <description>&lt;P&gt;Post LOG information into a code box as well. Then we can cut an paste to show corrections or explanations.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 16:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/417114#M26851</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-11-29T16:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop in data step</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/417255#M26861</link>
      <description>Thanks, RW9! Cool solution! I didn't know about BY statement in loop.</description>
      <pubDate>Wed, 29 Nov 2017 22:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Do-loop-in-data-step/m-p/417255#M26861</guid>
      <dc:creator>kanivan51</dc:creator>
      <dc:date>2017-11-29T22:07:26Z</dc:date>
    </item>
  </channel>
</rss>

