<?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: ERROR: Macro function %SCAN has too many arguments. after using prxchange in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317562#M69557</link>
    <description>&lt;P&gt;Your macro variable NAME_MOD is resolving to a string which contains a comma:&lt;/P&gt;
&lt;P&gt;57 %put &amp;amp;name_mod;&lt;BR /&gt;Philip, Russel 14&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hence the %scan() looks like:&lt;BR /&gt;%scan(&lt;SPAN&gt;Philip, Russel 14,2,&amp;amp;sep.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and Russel 14 is not a number which the second parameter should be.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The question really however is why your doing it this way in the first place. &amp;nbsp;You have a dataset - something which contains data - and then you are putting it in macro - which is just there to generate text. &amp;nbsp;Doesn't make sense. &amp;nbsp;Macro is not executable code, use Base SAS which is what its for.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Dec 2016 11:38:14 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-12-08T11:38:14Z</dc:date>
    <item>
      <title>ERROR: Macro function %SCAN has too many arguments. after using prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317548#M69549</link>
      <description>&lt;P&gt;After having modified the field entries using prxchange function and saving the result in a macro variable the macro function %scan()&lt;/P&gt;&lt;P&gt;gives the following error:&amp;nbsp;ERROR: Macro function %SCAN has too many arguments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here a working example:&lt;/P&gt;&lt;P&gt;data AAA;&lt;BR /&gt;input name &amp;amp;$20. age ;&lt;BR /&gt;datalines;&lt;BR /&gt;Philip- Russel 14&lt;BR /&gt;Ronald- Marc 15&lt;BR /&gt;Mary- Jane 16&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table AAA as&lt;BR /&gt;select name, prxchange('s/(\w+)- (\w+)/$1, $2/',-1, name) as name_mod, age&lt;BR /&gt;from AAA;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc print;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select name, name_mod, age&lt;BR /&gt;into :name separated by "~",&lt;BR /&gt;:name_mod separated by "~",&lt;BR /&gt;:age separated by "~"&lt;BR /&gt;&lt;BR /&gt;from AAA;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%let sep="~";&lt;BR /&gt;%put &amp;amp;name;&lt;BR /&gt;%put &amp;amp;name_mod;&lt;BR /&gt;%put &amp;amp;age;&lt;BR /&gt;%put %scan(&amp;amp;name,2,&amp;amp;sep);&lt;BR /&gt;%put %scan(&amp;amp;name_mod,2,&amp;amp;sep);&lt;BR /&gt;%put %scan(&amp;amp;age,2,&amp;amp;sep);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know why it is happening?&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 10:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317548#M69549</guid>
      <dc:creator>bianco</dc:creator>
      <dc:date>2016-12-08T10:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Macro function %SCAN has too many arguments. after using prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317552#M69551</link>
      <description>I found the answer:&lt;BR /&gt;&lt;A href="http://stackoverflow.com/questions/39889137/error-in-simple-sas-macro" target="_blank"&gt;http://stackoverflow.com/questions/39889137/error-in-simple-sas-macro&lt;/A&gt;</description>
      <pubDate>Thu, 08 Dec 2016 11:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317552#M69551</guid>
      <dc:creator>bianco</dc:creator>
      <dc:date>2016-12-08T11:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Macro function %SCAN has too many arguments. after using prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317562#M69557</link>
      <description>&lt;P&gt;Your macro variable NAME_MOD is resolving to a string which contains a comma:&lt;/P&gt;
&lt;P&gt;57 %put &amp;amp;name_mod;&lt;BR /&gt;Philip, Russel 14&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hence the %scan() looks like:&lt;BR /&gt;%scan(&lt;SPAN&gt;Philip, Russel 14,2,&amp;amp;sep.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and Russel 14 is not a number which the second parameter should be.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The question really however is why your doing it this way in the first place. &amp;nbsp;You have a dataset - something which contains data - and then you are putting it in macro - which is just there to generate text. &amp;nbsp;Doesn't make sense. &amp;nbsp;Macro is not executable code, use Base SAS which is what its for.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 11:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317562#M69557</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-12-08T11:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Macro function %SCAN has too many arguments. after using prxchange</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317567#M69560</link>
      <description>&lt;PRE&gt;
Use %bquote() to mask comma which is special character for macro facility.


data AAA;
input name &amp;amp;$20. age ;
datalines;
Philip- Russel  14
Ronald- Marc  15
Mary- Jane  16
;
proc sql;
create table AAA as
select name, prxchange('s/(\w+)- (\w+)/$1, $2/',-1, name) as name_mod, age
from AAA;
quit;
proc print;
run;

proc sql;
select name, name_mod, age
into :name separated by "~",
:name_mod separated by "~",
:age separated by "~"

from AAA;
quit;
%let sep=~;
%put &amp;amp;name;
%put &amp;amp;name_mod;
%put &amp;amp;age;
%put %scan(&amp;amp;name,2,&amp;amp;sep);
%put %scan(%bquote(&amp;amp;name_mod),2,&amp;amp;sep);
%put %scan(&amp;amp;age,2,&amp;amp;sep);

&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Dec 2016 11:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Macro-function-SCAN-has-too-many-arguments-after-using/m-p/317567#M69560</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-08T11:44:17Z</dc:date>
    </item>
  </channel>
</rss>

