<?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 with a list of Full Names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SCAN-with-a-list-of-Full-Names/m-p/607160#M176415</link>
    <description>&lt;P&gt;1) The macro language has its own %scan function, so no need to us %sysfunc.&lt;/P&gt;
&lt;P&gt;2) in general passing lists with comma's causes problems because the first comma encountered is going to be treated as a delimiter between successive parameters.&lt;/P&gt;
&lt;P&gt;3) really not a good idea to have macro variables just appear in the middle of the code you should have a parameter for the list&lt;/P&gt;
&lt;PRE&gt;%macro name_list (full_name_list);&lt;/PRE&gt;
&lt;P&gt;4) And passing a parameter with embedded commas would require use of&lt;/P&gt;
&lt;PRE&gt;%name_test( %str(HARRY LEVY, ABEL JAMES, ABHISHEK SINGH, ADAM LINKS) );&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5) No particular nasty code needed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let list=HARRY LEVY, ABEL JAMES, ABHISHEK SINGH, ADAM LINKS;

%let lastthird= %scan("&amp;amp;list",6);
%put &amp;amp;lastthird;&lt;/PRE&gt;
&lt;P&gt;Normally I would not put the &amp;amp;list in quotes but the comma's are also an issue for any macro function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Nov 2019 00:37:40 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-11-26T00:37:40Z</dc:date>
    <item>
      <title>SCAN with a list of Full Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-with-a-list-of-Full-Names/m-p/607151#M176412</link>
      <description>&lt;P&gt;I want a scan function within a macro that can pull last name of the third person in a list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put &amp;amp;full_name_list.&lt;/P&gt;&lt;P&gt;HARRY LEVY, ABEL JAMES, ABHISHEK SINGH, ADAM LINKS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro name_test();&lt;/P&gt;&lt;P&gt;%do array_counter = 1 %to &amp;amp;name_count.;&lt;BR /&gt;%let full_name = %SYSFUNC(SCAN(&amp;amp;FULL_NAME_LIST, &amp;amp;ARRAY_COUNTER, ','));&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%name_test();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the following error when I run this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: One or more missing close parentheses have been supplied for the %SCAN function.&lt;BR /&gt;ERROR: Expected close parenthesis after macro function invocation not found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I have a list of one name (either first or last) then this works perfectly. But I want to be able to pull the full name out. Any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 00:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-with-a-list-of-Full-Names/m-p/607151#M176412</guid>
      <dc:creator>waldo11</dc:creator>
      <dc:date>2019-11-26T00:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: SCAN with a list of Full Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-with-a-list-of-Full-Names/m-p/607160#M176415</link>
      <description>&lt;P&gt;1) The macro language has its own %scan function, so no need to us %sysfunc.&lt;/P&gt;
&lt;P&gt;2) in general passing lists with comma's causes problems because the first comma encountered is going to be treated as a delimiter between successive parameters.&lt;/P&gt;
&lt;P&gt;3) really not a good idea to have macro variables just appear in the middle of the code you should have a parameter for the list&lt;/P&gt;
&lt;PRE&gt;%macro name_list (full_name_list);&lt;/PRE&gt;
&lt;P&gt;4) And passing a parameter with embedded commas would require use of&lt;/P&gt;
&lt;PRE&gt;%name_test( %str(HARRY LEVY, ABEL JAMES, ABHISHEK SINGH, ADAM LINKS) );&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5) No particular nasty code needed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let list=HARRY LEVY, ABEL JAMES, ABHISHEK SINGH, ADAM LINKS;

%let lastthird= %scan("&amp;amp;list",6);
%put &amp;amp;lastthird;&lt;/PRE&gt;
&lt;P&gt;Normally I would not put the &amp;amp;list in quotes but the comma's are also an issue for any macro function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 00:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-with-a-list-of-Full-Names/m-p/607160#M176415</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-26T00:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: SCAN with a list of Full Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-with-a-list-of-Full-Names/m-p/607168#M176421</link>
      <description>&lt;P&gt;You tried to execute this mess:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let full_name_list=%sysfunc(scan(HARRY LEVY, ABEL JAMES, ABHISHEK SINGH, ADAM LINKS,1,','));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So SAS is complaining that you have given the SCAN() function 6 arguments.&amp;nbsp; That function does not have 6 arguments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have comma delimited list you will need to use macro quoting to protect the commas from becoming part of the command syntax. Also don't include quotes in the list of delimiters or else the SCAN(), or %SCAN(), function will use them as delimiters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to find an item in the list use something like this instead:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let full_name=%scan(%superq(full_name_list),&lt;SPAN&gt;&amp;amp;ARRAY_COUNTER&lt;/SPAN&gt;,%str(,));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2019 01:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-with-a-list-of-Full-Names/m-p/607168#M176421</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-26T01:32:52Z</dc:date>
    </item>
  </channel>
</rss>

