<?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 the output of the substr function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436087#M108422</link>
    <description>&lt;P&gt;As the &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0n08xougp40i5n1xw7njpcy0a2b.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=da" target="_self"&gt;documentation of the SUBSTR Function&lt;/A&gt; says:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"In a DATA step, if the SUBSTR (right of &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; function returns a value to a variable that has not previously been assigned a length, then that variable is given the length of the first argument."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Meaning that&amp;nbsp;substr(First,1,7) has the length 16,&amp;nbsp;', ' has the length 2 and&amp;nbsp;'England' has the length 7 giving the variable&amp;nbsp;City_Country a total length of 25.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Feb 2018 15:08:45 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-02-11T15:08:45Z</dc:date>
    <item>
      <title>length of the output of the substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436085#M108420</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm preparing the sas base certification but there is a point that I don't understand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The question is to give the length of City_Country after the following program is submitted:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.test;&lt;BR /&gt;First = 'Ipswich, England';&lt;BR /&gt;City_Country = substr(First,1,7)!!', '!!'England';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apparently the answer is 25, but why is it not 16? (&lt;SPAN&gt;Ipswich+, +England), is there a mistake in the solution?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2018 14:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436085#M108420</guid>
      <dc:creator>prehendere</dc:creator>
      <dc:date>2018-02-11T14:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: length of the output of the substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436086#M108421</link>
      <description>&lt;P&gt;From the documentation (&amp;nbsp;&lt;A href="https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm&lt;/A&gt; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;The concatenation operator (||) concatenates character values.
The results of a concatenation operation are usually stored in
a variable with an assignment statement, as in 
level='grade '||'A' . The length of the resulting variable is
the sum of the lengths of each variable or constant in the
concatenation operation, unless you use a LENGTH or ATTRIB
statement to specify a different length for the new variable.&lt;/PRE&gt;
&lt;P&gt;Thus, the length of first (16) + the lengths of ', ' and 'England'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2018 15:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436086#M108421</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-02-11T15:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: length of the output of the substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436087#M108422</link>
      <description>&lt;P&gt;As the &lt;A href="http://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n0n08xougp40i5n1xw7njpcy0a2b.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=da" target="_self"&gt;documentation of the SUBSTR Function&lt;/A&gt; says:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"In a DATA step, if the SUBSTR (right of &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; function returns a value to a variable that has not previously been assigned a length, then that variable is given the length of the first argument."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Meaning that&amp;nbsp;substr(First,1,7) has the length 16,&amp;nbsp;', ' has the length 2 and&amp;nbsp;'England' has the length 7 giving the variable&amp;nbsp;City_Country a total length of 25.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Feb 2018 15:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436087#M108422</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-02-11T15:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: length of the output of the substr function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436088#M108423</link>
      <description>thank you!</description>
      <pubDate>Sun, 11 Feb 2018 15:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/length-of-the-output-of-the-substr-function/m-p/436088#M108423</guid>
      <dc:creator>prehendere</dc:creator>
      <dc:date>2018-02-11T15:34:55Z</dc:date>
    </item>
  </channel>
</rss>

