<?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: Plz explain how %scan is working in below program. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899051#M40037</link>
    <description>&lt;P&gt;If you don't specify explicit characters as delimiters then the default list will get used. This applies both for scan() and %scan() and is &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1nhhymw6gxixvn1johcfl6kaygw.htm" target="_self"&gt;fully documented&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1697596444577.png" style="width: 977px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88928i23E46CC2FCF377FE/image-dimensions/977x184?v=v2" width="977" height="184" role="button" title="Patrick_0-1697596444577.png" alt="Patrick_0-1697596444577.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Oct 2023 02:35:52 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-10-18T02:35:52Z</dc:date>
    <item>
      <title>Plz explain how %scan is working in below program.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899042#M40034</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="POOJA_J_0-1697593798413.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88923iD8B32858EB9B7FB0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="POOJA_J_0-1697593798413.png" alt="POOJA_J_0-1697593798413.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I supposed the answer to be Buenos Aires.&lt;/P&gt;
&lt;P&gt;But I get Buenos Aires, Argentina as correct ans.&lt;/P&gt;
&lt;P&gt;Plz explain how the this works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 01:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899042#M40034</guid>
      <dc:creator>POOJA_J</dc:creator>
      <dc:date>2023-10-18T01:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Plz explain how %scan is working in below program.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899046#M40035</link>
      <description>&lt;P&gt;Please always share code as text and not as screenshot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let location=%str(Buenos Aires, Argentina);
%let city=%scan(&amp;amp;location, 1, %str(,));
%put &amp;amp;=city;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1nhhymw6gxixvn1johcfl6kaygw.htm" target="_self"&gt;documentation&lt;/A&gt; tells you that %scan() allows for FOUR parameters.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1697594687725.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88926i72EC86E146089D21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1697594687725.png" alt="Patrick_0-1697594687725.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The last comma in your code is not interpreted as the delimiter for the &lt;EM&gt;charlist&lt;/EM&gt; but as separator for the next parameter &lt;EM&gt;modifier&lt;/EM&gt;. This means that you define the value for &lt;EM&gt;charlist&lt;/EM&gt; blank meaning there isn't any.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get what you want quote the last comma so it gets used as value for charlist.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let location=%str(Buenos Aires, Argentina);
%let city=%scan(&amp;amp;location, 1, %str(,));
%put &amp;amp;=city;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 02:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899046#M40035</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-18T02:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Plz explain how %scan is working in below program.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899049#M40036</link>
      <description>Thanks for explaining. I have further question. &lt;BR /&gt;While using Scan function when we don't mention the delimiter, it considers all delimiters. The %scan won't behave the same? I mean suppose I don't mention the delimiter in %scan should it give ans as Buenos?</description>
      <pubDate>Wed, 18 Oct 2023 02:28:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899049#M40036</guid>
      <dc:creator>POOJA_J</dc:creator>
      <dc:date>2023-10-18T02:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Plz explain how %scan is working in below program.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899051#M40037</link>
      <description>&lt;P&gt;If you don't specify explicit characters as delimiters then the default list will get used. This applies both for scan() and %scan() and is &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1nhhymw6gxixvn1johcfl6kaygw.htm" target="_self"&gt;fully documented&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1697596444577.png" style="width: 977px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88928i23E46CC2FCF377FE/image-dimensions/977x184?v=v2" width="977" height="184" role="button" title="Patrick_0-1697596444577.png" alt="Patrick_0-1697596444577.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 02:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899051#M40037</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-18T02:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Plz explain how %scan is working in below program.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899052#M40038</link>
      <description>&lt;P&gt;But you did include it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just try it without the extra commas to get the default delimiters.&lt;/P&gt;
&lt;PRE&gt;1    %let location=%str(Buenos Aires, Argentina);
2    %put city=%scan(&amp;amp;location, 1, %str(,));
city=Buenos Aires
3    %put city=%scan(&amp;amp;location, 1);
city=Buenos
4    %put city=%scan(&amp;amp;location, 1,);
city=Buenos Aires, Argentina
5    %put city=%scan(&amp;amp;location, 1,,);
city=Buenos Aires, Argentina
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 02:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Plz-explain-how-scan-is-working-in-below-program/m-p/899052#M40038</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-18T02:36:01Z</dc:date>
    </item>
  </channel>
</rss>

