<?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 scan question (preparing SAS 9.4 Base) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/scan-question-preparing-SAS-9-4-Base/m-p/891278#M352108</link>
    <description>&lt;P&gt;Please&amp;nbsp; help me solve the question below. I appreciate your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which assignment statement extracts 2019 from the Text variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 data Scan_Quiz;&lt;BR /&gt;2 Text="New Year's Day, January 1st, 2019";&lt;BR /&gt;3 run;&lt;BR /&gt;4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A. 1 Year=scan(Text, 6);&lt;/P&gt;&lt;P&gt;B.&amp;nbsp;1 Year=scan(Text, 6, ', ');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know A is correct but I don't understand why B is correct too?&lt;/P&gt;&lt;P&gt;Under B, Test will be divided by 3&amp;nbsp;&lt;/P&gt;&lt;P&gt;New Year's Day&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; and&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;January 1st&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2019&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;because&amp;nbsp; ', ' has one comma and one space. Therefore I assumed B should be like below,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;B.&amp;nbsp;1 Year=scan(Text, 3, ', ');&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Aug 2023 08:31:48 GMT</pubDate>
    <dc:creator>TokyoSAS</dc:creator>
    <dc:date>2023-08-28T08:31:48Z</dc:date>
    <item>
      <title>scan question (preparing SAS 9.4 Base)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-question-preparing-SAS-9-4-Base/m-p/891278#M352108</link>
      <description>&lt;P&gt;Please&amp;nbsp; help me solve the question below. I appreciate your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which assignment statement extracts 2019 from the Text variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 data Scan_Quiz;&lt;BR /&gt;2 Text="New Year's Day, January 1st, 2019";&lt;BR /&gt;3 run;&lt;BR /&gt;4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A. 1 Year=scan(Text, 6);&lt;/P&gt;&lt;P&gt;B.&amp;nbsp;1 Year=scan(Text, 6, ', ');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know A is correct but I don't understand why B is correct too?&lt;/P&gt;&lt;P&gt;Under B, Test will be divided by 3&amp;nbsp;&lt;/P&gt;&lt;P&gt;New Year's Day&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; and&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;January 1st&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;and&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2019&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;because&amp;nbsp; ', ' has one comma and one space. Therefore I assumed B should be like below,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;B.&amp;nbsp;1 Year=scan(Text, 3, ', ');&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 08:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-question-preparing-SAS-9-4-Base/m-p/891278#M352108</guid>
      <dc:creator>TokyoSAS</dc:creator>
      <dc:date>2023-08-28T08:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: scan question (preparing SAS 9.4 Base)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-question-preparing-SAS-9-4-Base/m-p/891279#M352109</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/449417"&gt;@TokyoSAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is correct because there is a space after the comma in the specified delimiter, though it is difficult to see:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Year=scan(Text, 6, ', ');&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Year=scan(Text, 6, ',');&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Scan searches for any of the specified delimiters, so the string is split:&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"New | Year's | Day, |January | 1st, | 2019&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now you probably ask why the commas don't seem to count. They do, but both of the commas are followed by a space, and the default behaviour of scan is to consider two or more consecutive delimiters as one, so the spaces following the commas don't count.&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 09:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-question-preparing-SAS-9-4-Base/m-p/891279#M352109</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2023-08-28T09:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: scan question (preparing SAS 9.4 Base)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-question-preparing-SAS-9-4-Base/m-p/891280#M352110</link>
      <description>The space make that as valid separate delimiter as well, it's not the combination that is the delimiter.</description>
      <pubDate>Mon, 28 Aug 2023 09:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-question-preparing-SAS-9-4-Base/m-p/891280#M352110</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-08-28T09:12:52Z</dc:date>
    </item>
  </channel>
</rss>

