<?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 error problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470997#M120591</link>
    <description>&lt;P&gt;to %to &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jun 2018 08:31:59 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2018-06-18T08:31:59Z</dc:date>
    <item>
      <title>Do loop error problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470992#M120587</link>
      <description>&lt;P&gt;hello . I would like to generate several data set by using macro and do loop. but the log message keep alarming .&lt;/P&gt;&lt;P&gt;I don't know why eval is needed .&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data work.aa;&lt;BR /&gt;input a ;&lt;BR /&gt;cards;&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;7&lt;BR /&gt;8&lt;BR /&gt;9&lt;BR /&gt;10&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro do_loop ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%do i=1 %to 5 ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%do j=i+1 to %to 7 ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;data date&amp;amp;i.&amp;amp;j. ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set work.aa;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if 0&amp;lt;=a&amp;lt;&amp;amp;i then do ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;own1=1 ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;own2= 0 ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if &amp;amp;i&amp;lt;= a =&amp;lt;&amp;amp;j then&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;do;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;own1 = 0 ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;own2 = 0 ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else if &amp;amp;j &amp;lt; a &amp;lt;10 then do ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;own1 = 0 ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;own2 = 1 ;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;run;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; proc print; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %end ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%mend ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do_loop&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 08:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470992#M120587</guid>
      <dc:creator>LeeSeongWoo_</dc:creator>
      <dc:date>2018-06-18T08:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop error problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470993#M120588</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;%do j=i+1 to %to 7 ;&lt;BR /&gt;&lt;BR /&gt;=&amp;gt; %do j=&amp;amp;i.+1 %to 7;</description>
      <pubDate>Mon, 18 Jun 2018 08:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470993#M120588</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-06-18T08:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop error problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470994#M120589</link>
      <description>&lt;P&gt;Thank you for your reply . I missed it . but after fix it . error does not disappear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro do_loop ;&lt;BR /&gt;%do i=1 %to 5 ;&lt;BR /&gt;%do j=&amp;amp;i+1 to %to 7 ;&lt;/P&gt;&lt;P&gt;data date&amp;amp;i.&amp;amp;j. ;&lt;BR /&gt;set work.aa;&lt;/P&gt;&lt;P&gt;if 0&amp;lt;=a&amp;lt;&amp;amp;i then do ;&lt;BR /&gt;own1=1 ;&lt;BR /&gt;own2= 0 ;&lt;BR /&gt;end;&lt;BR /&gt;else if &amp;amp;i&amp;lt;= a =&amp;lt;&amp;amp;j then&lt;BR /&gt;do;&lt;BR /&gt;own1 = 0 ;&lt;BR /&gt;own2 = 0 ;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;else if &amp;amp;j &amp;lt; a &amp;lt;10 then do ;&lt;BR /&gt;own1 = 0 ;&lt;BR /&gt;own2 = 1 ;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;proc print; run;&lt;/P&gt;&lt;P&gt;%end ;&lt;BR /&gt;%end;&lt;BR /&gt;%mend ;&lt;/P&gt;&lt;P&gt;%do_loop&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 08:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470994#M120589</guid>
      <dc:creator>LeeSeongWoo_</dc:creator>
      <dc:date>2018-06-18T08:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop error problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470996#M120590</link>
      <description>&lt;P&gt;To use a macro variable, you always need the ampersand, and in macro %do statements, the "to" must also have a macro trigger:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i = 1 %to 5;
  %do j = &amp;amp;i+1 %to 7;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jun 2018 08:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470996#M120590</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-18T08:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop error problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470997#M120591</link>
      <description>&lt;P&gt;to %to &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 08:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/470997#M120591</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-06-18T08:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop error problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/471000#M120592</link>
      <description>&lt;P&gt;On top of everything else, compare this with your original code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro do_loop;
%do i = 1 %to 5;
  %do j = &amp;amp;i + 1 %to 7;

    data date&amp;amp;i.&amp;amp;j.;
    set work.aa;
    if 0 &amp;lt;= a &amp;lt; &amp;amp;i
    then do;
      own1 = 1;
      own2 = 0;
    end;
    else if &amp;amp;i &amp;lt;= a =&amp;lt; &amp;amp;j
    then do;
      own1 = 0;
      own2 = 0;
    end;
    else if &amp;amp;j &amp;lt; a &amp;lt; 10
    then do;
      own1 = 0;
      own2 = 1;
    end;
    run;

    proc print;
    run;

  %end;
%end;
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and decide which is more readable and easier to maintain.&lt;/P&gt;
&lt;P&gt;(consistent spacing and indentation)&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 08:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/471000#M120592</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-18T08:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop error problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/471001#M120593</link>
      <description>&lt;P&gt;To be honest, I am looking at that code and wondering what process could posible warrant a) 5 datasets with essentially the same data, and b) that code to get to it.&amp;nbsp; Makes no sense at all.&amp;nbsp; The essence of by group processing is to add groups within the existing data, then use those rather than creating lots of copies of data, then having to code loops over it etc.&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  &amp;lt;series of if statements&amp;gt;
    &amp;lt;assign group value&amp;gt;
run;

proc print data=want;
  by group_value;
run;
  &lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jun 2018 08:42:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-error-problem/m-p/471001#M120593</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-18T08:42:38Z</dc:date>
    </item>
  </channel>
</rss>

