<?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 AND LENGTH in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265119#M52085</link>
    <description>Thank u great job FreelanceReinhard</description>
    <pubDate>Wed, 20 Apr 2016 15:02:51 GMT</pubDate>
    <dc:creator>cons</dc:creator>
    <dc:date>2016-04-20T15:02:51Z</dc:date>
    <item>
      <title>SCAN FUNCTION AND LENGTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265090#M52071</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my name is Constantin. I need help with the subject above.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I dont get it. The manual says&lt;/P&gt;&lt;P&gt;"In a DATA step, if the SCAN function returns a value to a variable that has not yet been given a length, then that variable is given a length of 200 characters. If you need the SCAN function to assign to a variable a word that is longer than 200 characters, then you should explicitly specify the length of that variable".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok. I did try it, but it didnt work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;DATA data;&lt;/P&gt;&lt;P&gt;name=scan('Mr Smith',2);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the length 8. Please, help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bye.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 13:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265090#M52071</guid>
      <dc:creator>cons</dc:creator>
      <dc:date>2016-04-20T13:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: SCAN FUNCTION AND LENGTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265096#M52073</link>
      <description>&lt;P&gt;The manual is wrong here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many functions that return character strings, and for many of those the manual would be correct.&amp;nbsp; (For many additional character functions, the new variable would be assigned a length equal to the length of the incoming string.)&amp;nbsp; But SCAN returns a number, not a character string.&amp;nbsp; The default length for numbers is 8.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 13:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265096#M52073</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-20T13:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: SCAN FUNCTION AND LENGTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265102#M52076</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76801"&gt;@cons﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/67960/HTML/default/viewer.htm#p0jshdjy2z9zdzn1h7k90u99lyq6.htm" target="_blank"&gt;SAS &lt;STRONG&gt;9.4&lt;/STRONG&gt; documentation of the SCAN function&lt;/A&gt; says:&lt;/P&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. &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="xis-windowItem"&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;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="xis-windowItem"&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="xis-windowItem"&gt;So, I guess, you're using SAS 9.4, but&amp;nbsp;you read the documentation of an earlier SAS version. The string "Mr Smith" has a length of 8 characters, hence the length of variable NAME.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265102#M52076</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-20T14:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: SCAN FUNCTION AND LENGTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265108#M52078</link>
      <description>&lt;P&gt;Are you sure about that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The manual is wrong here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many functions that return character strings, and for many of those the manual would be correct.&amp;nbsp; (For many additional character functions, the new variable would be assigned a length equal to the length of the incoming string.)&amp;nbsp; But SCAN returns a number, not a character string.&amp;nbsp; The default length for numbers is 8.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265108#M52078</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-04-20T14:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: SCAN FUNCTION AND LENGTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265111#M52080</link>
      <description>&lt;P&gt;No, my mistake.&amp;nbsp; I was mixing together two functions.&amp;nbsp; SCAN definitely returns a character string, not a number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you think about the result, this behavior makes sense.&amp;nbsp; SAS has to decide on a length for the new variable before it actually examines the data.&amp;nbsp; It is possible that SCAN will retrieve the entire incoming string, so to be safe it assigns the new variable the length of the incoming string.&amp;nbsp; Same behavior for SUBSTR.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 14:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265111#M52080</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-04-20T14:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: SCAN FUNCTION AND LENGTH</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265119#M52085</link>
      <description>Thank u great job FreelanceReinhard</description>
      <pubDate>Wed, 20 Apr 2016 15:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SCAN-FUNCTION-AND-LENGTH/m-p/265119#M52085</guid>
      <dc:creator>cons</dc:creator>
      <dc:date>2016-04-20T15:02:51Z</dc:date>
    </item>
  </channel>
</rss>

