<?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: Iterate over a list of numeric value in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681422#M206108</link>
    <description>&lt;P&gt;this time i want to iterate over a list of char variable. can I use same code?&lt;/P&gt;</description>
    <pubDate>Thu, 03 Sep 2020 16:18:06 GMT</pubDate>
    <dc:creator>mazouz</dc:creator>
    <dc:date>2020-09-03T16:18:06Z</dc:date>
    <item>
      <title>Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681369#M206080</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to creat a loop that that iterate over a list of numeric value like this :&lt;/P&gt;&lt;DIV class="line number2 index1 alt1"&gt;&lt;CODE class="functions"&gt;&lt;CODE class="functions"&gt;&lt;/CODE&gt;&lt;/CODE&gt;&lt;PRE&gt;LIST =&amp;gt; [1, 3, 5, 7, 20,100,2000]
&amp;nbsp;&amp;nbsp;&amp;nbsp;
%DO i  %IN LIST;&lt;/PRE&gt;&lt;CODE class="plain"&gt;&lt;/CODE&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Sep 2020 14:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681369#M206080</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-09-03T14:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681370#M206081</link>
      <description>&lt;P&gt;In a DATA step, this is how to do it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data nothing;
	do i= 1, 3, 5, 7, 20,100,2000;
	    output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681370#M206081</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-03T15:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681374#M206083</link>
      <description>&lt;P&gt;Do you need to do this in real SAS code?&amp;nbsp; Your syntax looks like IML are you using IML?&amp;nbsp; The data step also can use a comma separated list of values in a DO statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i= 1, 3, 5, 7, 20,100,2000;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Some of them can be ranges if you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i= 1 to 7 by 2, 20,100,2000;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you trying to use the macro processor to generate something?&amp;nbsp; The macro processor does not have any syntax for that.&amp;nbsp; Just make a list and iterate over an index into the list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list = 1 3 5 7 20 100 2000;
%do index = 1 %to %sysfunc(countw(&amp;amp;list,%str( )));
  %let I =%scan(&amp;amp;list,&amp;amp;index,%str( ));
....
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681374#M206083</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-03T15:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681383#M206086</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%let list = 1 3 5 7 20 100 2000;&lt;BR /&gt;
%MACRO WANT(variable,table);
%do index = 1 %to %sysfunc(countw(&amp;amp;list,%str( )));
%let I =%scan(&amp;amp;list,&amp;amp;index,%str( ));
%FUNCTION(&amp;amp;variable,&amp;amp;table,I);
%END;
%MEND;

%WANT(VAR1,HAVE);&lt;/PRE&gt;&lt;P&gt;I want to iterate function, I try this but don't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681383#M206086</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-09-03T15:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681385#M206088</link>
      <description>&lt;P&gt;Define how it doesn't work.&amp;nbsp; I notice that you are setting a value to I but you never use it.&amp;nbsp; Did you mean to use &amp;amp;I instead of I in the call to %FUNCTION() macro?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681385#M206088</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-03T15:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681395#M206093</link>
      <description>&lt;P&gt;Yes&lt;/P&gt;&lt;P&gt;%FUNCTION is a macro that i want to iterat for i in list&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681395#M206093</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-09-03T15:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681398#M206094</link>
      <description>&lt;P&gt;I don't know what %FUNCTION is, I don't have that macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, the rest of your code works fine if I comment out %FUNCTION&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let list = 1 3 5 7 20 100 2000;

%MACRO WANT(variable,table);
%do index = 1 %to %sysfunc(countw(&amp;amp;list,%str( )));
%let I =%scan(&amp;amp;list,&amp;amp;index,%str( ));
/*%FUNCTION(&amp;amp;variable,&amp;amp;table,I);*/
%put &amp;amp;=i;
%END;
%MEND;

%WANT(VAR1,HAVE)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps you should use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%FUNCTION(&amp;amp;variable,&amp;amp;table,&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt;I);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Important concept for your future reference: saying something "don't work" &lt;EM&gt;and providing no other information&lt;/EM&gt; is never helpful to us and is never helpful to you in resolving these issues.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681398#M206094</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-03T15:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681399#M206095</link>
      <description>&lt;P&gt;Here&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%FUNCTION(&amp;amp;variable,&amp;amp;table,I);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you feed the one-character &lt;EM&gt;text&lt;/EM&gt;&amp;nbsp;&lt;STRONG&gt;I&lt;/STRONG&gt; to your macro. If you wanted it to get the&amp;nbsp;&lt;EM&gt;value&lt;/EM&gt; stored in the macro variable I, you need to address it correctly:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%FUNCTION(&amp;amp;variable,&amp;amp;table,&amp;amp;I);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681399#M206095</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-03T15:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681400#M206096</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339736"&gt;@mazouz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes&lt;/P&gt;
&lt;P&gt;%FUNCTION is a macro that i want to iterat for i in list&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Does that macro want a number as the value of the third parameter or a macro variable name?&amp;nbsp; Currently you are just giving it the letter I.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%function(...,i)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to give it the values like 1 and 2000 instead then use &amp;amp;I in the call to the macro.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%function(....,&amp;amp;i)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681400#M206096</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-03T15:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681402#M206098</link>
      <description>thank you &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:39:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681402#M206098</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-09-03T15:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681422#M206108</link>
      <description>&lt;P&gt;this time i want to iterate over a list of char variable. can I use same code?&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 16:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681422#M206108</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-09-03T16:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate over a list of numeric value in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681423#M206109</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339736"&gt;@mazouz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;this time i want to iterate over a list of char variable. can I use same code?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Depending on how your macro %FUNCTION is written, the answer is either YES or NO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the macro loop that we are working with doesn't care if the values are numeric or character.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 16:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Iterate-over-a-list-of-numeric-value-in-SAS/m-p/681423#M206109</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-03T16:19:41Z</dc:date>
    </item>
  </channel>
</rss>

