<?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: Confusion in scan function in SAS Certification</title>
    <link>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897714#M1650</link>
    <description>Anytime you use SCAN in a WHERE statement, WHERE dataset option or SQL WHERE clause, the result is limited to 200 characters. If the substring extracted by the function exceeds 200 characters, it will be truncated.&lt;BR /&gt;This happens because a WHERE is always handled by SQL in the background.</description>
    <pubDate>Sun, 08 Oct 2023 13:23:26 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2023-10-08T13:23:26Z</dc:date>
    <item>
      <title>Confusion in scan function</title>
      <link>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897705#M1647</link>
      <description>&lt;P&gt;Hi everyone.&lt;/P&gt;&lt;P&gt;Please I need clarification on this;&lt;/P&gt;&lt;P&gt;In sas documentation here,&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001336080.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001336080.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It says;&amp;nbsp;&lt;SPAN&gt;The default length of a target variable where the expression contains the SCAN function is 200 bytes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then under the sub heading "saving storage space", it reads; The SCAN function causes SAS to assign a length of 200 bytes to the target variable in an assignment statement. Most of the other character functions cause the target to have the same length as the original value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When I tried the logic in sas 9.4 version, the latter is true i.e.&amp;nbsp;the target variable in the scan function gave the same length as the first argument.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Given this mcq question I saw online;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data work.test;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Author = 'Agatha Christie';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;First = substr(scan(author,1,' ,'),1,1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There were options&amp;nbsp;for 15 and 200.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please can you help to clarify this, I'm preparing for the sas base certification exam.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2023 05:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897705#M1647</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-10-08T05:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion in scan function</title>
      <link>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897706#M1648</link>
      <description>&lt;P&gt;Maxim 1: Read the Documentation.&lt;/P&gt;
&lt;P&gt;From&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0jshdjy2z9zdzn1h7k90u99lyq6.htm" target="_blank" rel="noopener"&gt;SCAN Function&lt;/A&gt;&amp;nbsp;:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;In a DATA step, if the SCAN function returns a value to a variable that has not yet been given a length, that variable is given the length of the first argument.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xisDoc-windowItem"&gt;&lt;STRONG&gt;This behavior is different from the behavior in previous releases of SAS. In previous releases, code that created a variable with a length of 200 might have produced a variable with a length that was greater than expected&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;If you need the SCAN function to assign a variable with a value that is different from the length of the first argument, use a LENGTH statement.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sun, 08 Oct 2023 05:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897706#M1648</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-08T05:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion in scan function</title>
      <link>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897713#M1649</link>
      <description>&lt;P&gt;from the documentation;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"If you use the SCAN function in an expression that contains operators or other functions, a word that is returned by the SCAN function can have a length of up to 32,767 characters, except in a WHERE clause. In that case, the maximum length is 200 characters."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please can you illustrate scan function in a "where clause" where the target variable return the the maximum length is 200?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2023 13:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897713#M1649</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-10-08T13:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion in scan function</title>
      <link>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897714#M1650</link>
      <description>Anytime you use SCAN in a WHERE statement, WHERE dataset option or SQL WHERE clause, the result is limited to 200 characters. If the substring extracted by the function exceeds 200 characters, it will be truncated.&lt;BR /&gt;This happens because a WHERE is always handled by SQL in the background.</description>
      <pubDate>Sun, 08 Oct 2023 13:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897714#M1650</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-08T13:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Confusion in scan function</title>
      <link>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897943#M1656</link>
      <description>&lt;P&gt;Thank you, I get it now&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 12:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/Confusion-in-scan-function/m-p/897943#M1656</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-10-10T12:19:11Z</dc:date>
    </item>
  </channel>
</rss>

