<?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: Length of a variable which is getting assigned using Scan function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209391#M38845</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My bad, I am using SAS 9.4 but was looking at SAS 9.2 documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for pointing that out. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 06 May 2015 03:22:18 GMT</pubDate>
    <dc:creator>NikhilKhurana</dc:creator>
    <dc:date>2015-05-06T03:22:18Z</dc:date>
    <item>
      <title>Length of a variable which is getting assigned using Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209388#M38842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was reading Scan function on support site (&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm" title="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;) . It is written that, 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;&lt;/P&gt;&lt;P&gt;But when I am executing the below data steps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;title = 'Writing as much Macros as possible so that they can be used in other modules as well.';&lt;/P&gt;&lt;P&gt;word=scan(title,1,' ');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test2;&lt;/P&gt;&lt;P&gt;word=scan('Writing as much Macros as possible so that they can be used in other modules as well.',1,' ');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The length of variable word in both the data sets is 85 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just need to understand why is the length not 200 and 85.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 05:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209388#M38842</guid>
      <dc:creator>NikhilKhurana</dc:creator>
      <dc:date>2015-05-05T05:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Length of a variable which is getting assigned using Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209389#M38843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to look at the documentation for the version of SAS that you are actually using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #353535; font-family: lato, arial, 'Arial Unicode MS', geneva, 'Lucida Grande', sans-serif; background-color: #ffffff;"&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. If you need the SCAN function to assign to a variable a value that is different from the length of the first argument, use a LENGTH statement for that variable before the statement that uses the SCAN function.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 12:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209389#M38843</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-05-05T12:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Length of a variable which is getting assigned using Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209390#M38844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;you should explicitly specify the length of that variable"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;IMO you should always explicitly state the length of a variable.&amp;nbsp; Otherwise you may get differing results if the data changes.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 13:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209390#M38844</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-05T13:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Length of a variable which is getting assigned using Scan function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209391#M38845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My bad, I am using SAS 9.4 but was looking at SAS 9.2 documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for pointing that out. &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 May 2015 03:22:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Length-of-a-variable-which-is-getting-assigned-using-Scan/m-p/209391#M38845</guid>
      <dc:creator>NikhilKhurana</dc:creator>
      <dc:date>2015-05-06T03:22:18Z</dc:date>
    </item>
  </channel>
</rss>

