<?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 using %scan in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-using-scan/m-p/683792#M207142</link>
    <description>&lt;P&gt;This is a duplicate question. Please do not post duplicate questions. I have answered your question in your other thread at &lt;A href="https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/td-p/683788" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/td-p/683788&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Sep 2020 22:24:04 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-09-14T22:24:04Z</dc:date>
    <item>
      <title>Do Loop using %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-using-scan/m-p/683789#M207139</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Can you please help me with this looping process through name stored in NAMELIST variable?&lt;/P&gt;
&lt;P&gt;I am not sure what is missing.&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Error notice is:&lt;/P&gt;
&lt;P&gt;ERROR: Macro function %SCAN has too many arguments. The excess arguments will be ignored.&lt;BR /&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric&lt;BR /&gt;operand is required. The condition was: Alice&lt;BR /&gt;ERROR: Argument 2 to macro function %SCAN is not a number.&lt;BR /&gt;name 1 is&lt;BR /&gt;ERROR: The macro DOPRINT will stop executing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
select name into :NAMELIST  separated by ','
from sashelp.class
; quit;
%put &amp;amp;NAMELIST ;

%macro doprint;
	%do i=1 %to 10;
		%put name &amp;amp;i is %scan(&amp;amp;NAMELIST,&amp;amp;i);
	%end;
%mend;
%doprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 22:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-using-scan/m-p/683789#M207139</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2020-09-14T22:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop using %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-using-scan/m-p/683792#M207142</link>
      <description>&lt;P&gt;This is a duplicate question. Please do not post duplicate questions. I have answered your question in your other thread at &lt;A href="https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/td-p/683788" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Proc-SQL-save-multiple-value-to-macro-variable/td-p/683788&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 22:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-using-scan/m-p/683792#M207142</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-14T22:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Do Loop using %scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Do-Loop-using-scan/m-p/683793#M207143</link>
      <description>&lt;P&gt;Commas are the delimiter in the %scan function. You have placed commas in the body of your NAMELIST variable. So each comma appearing inside Namelist is treated as a delimiter resulting in "too many" parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your shown code will work if you use "separated by ' ' " in the select into.&lt;/P&gt;
&lt;P&gt;Or use a quoting function to "hide" the commas from that use such as&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;%scan(%bquote(&amp;amp;NAMELIST) ,&amp;amp;i);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Sep 2020 22:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Do-Loop-using-scan/m-p/683793#M207143</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-14T22:25:56Z</dc:date>
    </item>
  </channel>
</rss>

