<?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: Scan function macro in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416925#M67669</link>
    <description>&lt;P&gt;Why are you specifying the delimiter for %SCAN() but not for COUNTW()?&lt;/P&gt;
&lt;P&gt;Why are you quoting the commas in &amp;amp;XY for the COUNTW() function, but not for the %SCAN() function?&lt;/P&gt;
&lt;P&gt;Why did you include single quote character in the list of delimiters?&amp;nbsp; If they are valid delimiters then you can use ',' as the delimiter specification and you will not need to use macro quoting since the actual quotes will prevent SAS from thinking the comma is part of the function call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
%local xy n h cname ;
%let xy= XOP  PM , XOP DD, X/Y/N, EPP,ACC,ENN;
%let n=%sysfunc(countw(%bquote(&amp;amp;xy),%str(,)));

%do h=1 %to &amp;amp;n;
  %let cname = %scan(%qupcase(&amp;amp;xy),&amp;amp;h,%str(,));
  %put H=&amp;amp;h CNAME="&amp;amp;cname";
%end;

%mend test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;6881   %test;
H=1 CNAME="XOP  PM"
H=2 CNAME="XOP DD"
H=3 CNAME="X/Y/N"
H=4 CNAME="EPP"
H=5 CNAME="ACC"
H=6 CNAME="ENN"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2017 01:26:01 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-11-29T01:26:01Z</dc:date>
    <item>
      <title>Scan function macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416924#M67668</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note : XOP PM is one word and XOP DD is one word&amp;nbsp; and X/Y/N is one word&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;%let xy= XOP&amp;nbsp; PM&amp;nbsp;, XOP DD, X/Y/N, EPP,ACC,ENN;&lt;/P&gt;&lt;P&gt;want to scan how many word I have&lt;/P&gt;&lt;P&gt;answer &amp;nbsp;should be 6&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; n=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(countw(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%bquote&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;xy)));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; h=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;n;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;cname = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%upcase&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%scan&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;xy,&amp;amp;h.,&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(',')));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%END&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%PUT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;cname;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%mend;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;So first time cname should be XOP PM and second time&amp;nbsp;cname should be XOP DD and third time cname should be X/Y/N&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Can u please help &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 01:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416924#M67668</guid>
      <dc:creator>Julia22</dc:creator>
      <dc:date>2017-11-29T01:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Scan function macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416925#M67669</link>
      <description>&lt;P&gt;Why are you specifying the delimiter for %SCAN() but not for COUNTW()?&lt;/P&gt;
&lt;P&gt;Why are you quoting the commas in &amp;amp;XY for the COUNTW() function, but not for the %SCAN() function?&lt;/P&gt;
&lt;P&gt;Why did you include single quote character in the list of delimiters?&amp;nbsp; If they are valid delimiters then you can use ',' as the delimiter specification and you will not need to use macro quoting since the actual quotes will prevent SAS from thinking the comma is part of the function call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
%local xy n h cname ;
%let xy= XOP  PM , XOP DD, X/Y/N, EPP,ACC,ENN;
%let n=%sysfunc(countw(%bquote(&amp;amp;xy),%str(,)));

%do h=1 %to &amp;amp;n;
  %let cname = %scan(%qupcase(&amp;amp;xy),&amp;amp;h,%str(,));
  %put H=&amp;amp;h CNAME="&amp;amp;cname";
%end;

%mend test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;6881   %test;
H=1 CNAME="XOP  PM"
H=2 CNAME="XOP DD"
H=3 CNAME="X/Y/N"
H=4 CNAME="EPP"
H=5 CNAME="ACC"
H=6 CNAME="ENN"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 01:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416925#M67669</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-29T01:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Scan function macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416941#M67670</link>
      <description>&lt;P&gt;Use COUNTC function&amp;nbsp;&lt;/P&gt;&lt;P&gt;wordsn=sum(countc(sourcevar,","),1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you can proceed with your code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 02:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416941#M67670</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-11-29T02:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: Scan function macro</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416959#M67672</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you So much&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 05:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Scan-function-macro/m-p/416959#M67672</guid>
      <dc:creator>Julia22</dc:creator>
      <dc:date>2017-11-29T05:26:34Z</dc:date>
    </item>
  </channel>
</rss>

