<?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 for nonconsecutive number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884069#M349261</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107944"&gt;@Visiting&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to develop a do loop for nonconsecutive number like:&lt;/P&gt;
&lt;P&gt;1 to 45, plus 101, 105&lt;/P&gt;
&lt;P&gt;How to writhe the code?&lt;/P&gt;
&lt;P&gt;I tried %do i=1 % to 45, 101, 105, but doesn't work. Any suggestion? Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is easy to do with a DO loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to 45,101,105 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is harder with a macro %DO loop as the macro %DO statement is not as powerful as the data step DO loop.&lt;/P&gt;</description>
    <pubDate>Sun, 09 Jul 2023 03:12:28 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-07-09T03:12:28Z</dc:date>
    <item>
      <title>Do loop for nonconsecutive number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884065#M349259</link>
      <description>&lt;P&gt;I am trying to develop a do loop for nonconsecutive number like:&lt;/P&gt;&lt;P&gt;1 to 45, plus 101, 105&lt;/P&gt;&lt;P&gt;How to writhe the code?&lt;/P&gt;&lt;P&gt;I tried %do i=1 % to 45, 101, 105, but doesn't work. Any suggestion? Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jul 2023 22:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884065#M349259</guid>
      <dc:creator>Visiting</dc:creator>
      <dc:date>2023-07-08T22:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop for nonconsecutive number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884068#M349260</link>
      <description>&lt;P&gt;Just create a separate loop variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to 47;
  %if &amp;amp;i &amp;lt;= 45 %then %let j = &amp;amp;i;
  %else %if &amp;amp;i = 46 %then %let j = 101;
  %else %if &amp;amp;i = 47 %then %let j = 105;
    %put j = &amp;amp;j;
  %* more statements;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Jul 2023 01:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884068#M349260</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-07-09T01:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop for nonconsecutive number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884069#M349261</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107944"&gt;@Visiting&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to develop a do loop for nonconsecutive number like:&lt;/P&gt;
&lt;P&gt;1 to 45, plus 101, 105&lt;/P&gt;
&lt;P&gt;How to writhe the code?&lt;/P&gt;
&lt;P&gt;I tried %do i=1 % to 45, 101, 105, but doesn't work. Any suggestion? Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is easy to do with a DO loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to 45,101,105 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It is harder with a macro %DO loop as the macro %DO statement is not as powerful as the data step DO loop.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2023 03:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884069#M349261</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-09T03:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Do loop for nonconsecutive number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884248#M349331</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/107944"&gt;@Visiting&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to develop a do loop for nonconsecutive number like:&lt;/P&gt;
&lt;P&gt;1 to 45, plus 101, 105&lt;/P&gt;
&lt;P&gt;How to writhe the code?&lt;/P&gt;
&lt;P&gt;I tried %do i=1 % to 45, 101, 105, but doesn't work. Any suggestion? Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;"Doesn't work" is such a vague description as to be meaningless.&lt;/P&gt;
&lt;P&gt;I suspect that you get an ERROR message similar to&lt;/P&gt;
&lt;PRE&gt;ERROR: A character operand was found in the %EVAL function or %IF
       condition where a numeric operand is required.
&lt;/PRE&gt;
&lt;P&gt;If so you should include complete code, entire data step, procedure and/or macro definition and the error messages &lt;STRONG&gt;from the log&lt;/STRONG&gt;. Copy and paste the text into a text box opened on the forum with the &amp;lt;/&amp;gt; icon above the message window. Then possible describe what the result should be as it is impossible to tell from your incomplete snippet&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;Note that your code is incomplete for the macro language as it should be %to not 'to' with the %do.&lt;/P&gt;
&lt;P&gt;The comma is not part of a numeric value so that throws the character operand as %to expects something that resolves to an integer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 19:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-loop-for-nonconsecutive-number/m-p/884248#M349331</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-07-10T19:53:38Z</dc:date>
    </item>
  </channel>
</rss>

