<?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 -need help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311239#M67210</link>
    <description>&lt;P&gt;Hey,&lt;/P&gt;
&lt;P&gt;Cats, Catx, and Cat func always give 200 bytes len for the resulting var, untill unless you do'nt define the length explicitly,&lt;/P&gt;
&lt;P&gt;if you use || to concat then you get len of word 1 + word 2, so in ur case&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you use&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#003399"&gt;data work.words;
   word1='Is';
   word2='It';
   all=(word1||word2;
run;&lt;BR /&gt;&lt;BR /&gt;proc conetnts;run;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;in this case you will find 4 len for all variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 13 Nov 2016 12:54:43 GMT</pubDate>
    <dc:creator>LittlesasMaster</dc:creator>
    <dc:date>2016-11-13T12:54:43Z</dc:date>
    <item>
      <title>scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311237#M67209</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question. Which is the different between this picture?&lt;/P&gt;&lt;P&gt;I don.t understand when the lenght is 200 bytes or the lenght of variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;The following SAS program is submitted: &lt;FONT color="#003399"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;PRE&gt;&lt;FONT color="#003399"&gt;data work.test;
   title="Hitchhiker's Guide to SAS's Functions";
   word=scan(title,5," ,':");
run;&lt;/FONT&gt;&lt;/PRE&gt;What is the value and length of the variable &lt;CODE&gt;Word&lt;/CODE&gt; in the output data set?&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;a.&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;The value is &lt;EM&gt;Functions&lt;/EM&gt; and the length is 9 bytes.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;b.&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;The value is &lt;EM&gt;Functions&lt;/EM&gt; and the length is 37 bytes.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;c.&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;The value is &lt;EM&gt;SAS&lt;/EM&gt; and the length is 37 bytes.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;d.&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;The value is &lt;EM&gt;SAS&lt;/EM&gt; and the length is 200 bytes.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;STRONG&gt;Correct&amp;nbsp;answer:&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT color="#003399"&gt;c&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Your&amp;nbsp;answer:&amp;nbsp;&amp;nbsp;&lt;FONT color="#003399"&gt;d&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&lt;BR /&gt;As of SAS 9.4, 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. In this case, the length of the variable word is 37, the same as the variable title.&lt;A href="https://support.sas.com/edu/OLTRN/ECBPRGPE/m0002/base9quizx.htm#topofpage" target="_blank"&gt;&lt;IMG src="https://support.sas.com/eduapp/elearning/images/en/navimages/button.gif" border="0" alt="Return to top" width="15" height="14" /&gt;&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;The following SAS program is submitted:&lt;/P&gt;&lt;PRE&gt;&lt;FONT color="#003399"&gt;data work.words;
   word1='Is';
   word2='It';
   all=catx(' ',word1,word2);
run;&lt;/FONT&gt;&lt;/PRE&gt;The variable &lt;CODE&gt;All&lt;/CODE&gt; is a character variable of what size?&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;a.&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;200 -- standard default size&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;b.&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;4 -- all of the characters added together&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;c.&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;5 -- all of the characters and 1 space&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;EM&gt;d.&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;8 -- character default size of 8&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;STRONG&gt;Correct&amp;nbsp;answer:&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;FONT color="#003399"&gt; a&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!!!!!!!!&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2016 12:35:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311237#M67209</guid>
      <dc:creator>beatraca</dc:creator>
      <dc:date>2016-11-13T12:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311239#M67210</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;
&lt;P&gt;Cats, Catx, and Cat func always give 200 bytes len for the resulting var, untill unless you do'nt define the length explicitly,&lt;/P&gt;
&lt;P&gt;if you use || to concat then you get len of word 1 + word 2, so in ur case&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you use&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#003399"&gt;data work.words;
   word1='Is';
   word2='It';
   all=(word1||word2;
run;&lt;BR /&gt;&lt;BR /&gt;proc conetnts;run;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;in this case you will find 4 len for all variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2016 12:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311239#M67210</guid>
      <dc:creator>LittlesasMaster</dc:creator>
      <dc:date>2016-11-13T12:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311254#M67216</link>
      <description>I don,t understand you!! because in my first example I have scan I don,t know because the lenght isn,t 200 and the second example yes!</description>
      <pubDate>Sun, 13 Nov 2016 16:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311254#M67216</guid>
      <dc:creator>beatraca</dc:creator>
      <dc:date>2016-11-13T16:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311255#M67217</link>
      <description>&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, 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;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2016 17:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311255#M67217</guid>
      <dc:creator>LittlesasMaster</dc:creator>
      <dc:date>2016-11-13T17:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311256#M67218</link>
      <description>&lt;P&gt;1- 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;&lt;SPAN&gt;&amp;nbsp; 2- &amp;nbsp;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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3- &amp;nbsp;&lt;/SPAN&gt;In the SQL procedure, or in a WHERE clause in any procedure, the maximum length of a word that is returned by the SCAN function is 200 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4- In the macro processor, the maximum length of a word that is returned by the SCAN function is 65,534 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Source :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214639.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2016 17:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311256#M67218</guid>
      <dc:creator>LittlesasMaster</dc:creator>
      <dc:date>2016-11-13T17:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311257#M67219</link>
      <description>then, because in my first example the solution isn,t 200??&lt;BR /&gt;</description>
      <pubDate>Sun, 13 Nov 2016 17:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311257#M67219</guid>
      <dc:creator>beatraca</dc:creator>
      <dc:date>2016-11-13T17:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311262#M67224</link>
      <description>Hi:&lt;BR /&gt;  In the "old" days, SCAN did return a length of $200 when you created a new variable using SCAN. But, as the note indicates in the explanation for the right answer, starting with SAS 9.4, if you do not explicitly specify a length, then SCAN uses the length of the first argument to the function (instead of $200) -- on the theory that if you are extracting a piece of the first argument, the returned size can't be bigger than the length of the first argument.&lt;BR /&gt;&lt;BR /&gt;Just because CAT,CATX, CATT functions work with creating one length, you can't assume that all character functions work the same. &lt;BR /&gt;&lt;BR /&gt;  A good rule of thumb is to always use a LENGTH statement when creating new character variables, then you are in control of the LENGTH that will be used instead of the default, whatever it is.&lt;BR /&gt;&lt;BR /&gt;  (If you look in the doc for the CAT function, for example, &lt;A href="http://support.sas.com/documentation/cdl/en/ds2ref/68052/HTML/default/viewer.htm#n0somj6dsx2dmkn1vqjabhvt6nv4.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/ds2ref/68052/HTML/default/viewer.htm#n0somj6dsx2dmkn1vqjabhvt6nv4.htm&lt;/A&gt; you will see that $200 is not always the length used.)&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Sun, 13 Nov 2016 17:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311262#M67224</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-11-13T17:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311264#M67226</link>
      <description>Hi Cyntia,&lt;BR /&gt;Then, do SAS 9.4 always have the lenght of the first argument to the function alway ?</description>
      <pubDate>Sun, 13 Nov 2016 17:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311264#M67226</guid>
      <dc:creator>beatraca</dc:creator>
      <dc:date>2016-11-13T17:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311299#M67241</link>
      <description>No -- the length of the new variable really depends on the function you are using. That was why I pasted the link for the CAT function in my previous posting. So, by comparison to SCAN, you could see that CAT was different.&lt;BR /&gt;&lt;BR /&gt;  I really recommend a review of the documentation for the character functions that you use most often. As I indicated, it is considered a best practice to use a LENGTH statement so you do not have to count on the defaults.&lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Mon, 14 Nov 2016 02:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311299#M67241</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2016-11-14T02:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: scan function -need help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311311#M67247</link>
      <description>&lt;PRE&gt;
I remember @Astounding said before.
SAS will decide the length of variable before applying a function.
Therefore SAS will take SCAN's variable length as response variable length.
But for CATX() , SAS can't decide the variable length ,so using 200 as default length.

&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Nov 2016 03:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/scan-function-need-help/m-p/311311#M67247</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-11-14T03:44:56Z</dc:date>
    </item>
  </channel>
</rss>

