<?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: Problem with Substr function in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-Substr-function/m-p/70781#M20382</link>
    <description>It works ok here: &lt;BR /&gt;
&lt;BR /&gt;
data test ;&lt;BR /&gt;
  Region1='TEST Division' ;&lt;BR /&gt;
  RegLen = length(Region1) ;&lt;BR /&gt;
&lt;BR /&gt;
  if substr(Region1,RegLen-7,8) = "Division" then&lt;BR /&gt;
  Region2 = cat(Region1," Support") ;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Contents of dataset test:&lt;BR /&gt;
&lt;BR /&gt;
Region1             RegLen        Region2&lt;BR /&gt;
TEST Division            13        Test Division Support</description>
    <pubDate>Thu, 22 Jan 2009 12:43:38 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-01-22T12:43:38Z</dc:date>
    <item>
      <title>Problem with Substr function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-Substr-function/m-p/70780#M20381</link>
      <description>I am trying to use the following code where Region1 is a string variable&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
RegLen = length(Region1);&lt;BR /&gt;
&lt;BR /&gt;
if substr(Region1,RegLen-7,8) = "Division" then&lt;BR /&gt;
	Region2 = cat(Region1," Support");&lt;BR /&gt;
&lt;BR /&gt;
For some reason this won't work and the error occures at 'RegLen-7' in the substr function.  when I replace this with a number, 14 for example' it works, but as Region1 can be any number of characters long I need this calculation in there.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 22 Jan 2009 11:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-Substr-function/m-p/70780#M20381</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-22T11:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Substr function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-Substr-function/m-p/70781#M20382</link>
      <description>It works ok here: &lt;BR /&gt;
&lt;BR /&gt;
data test ;&lt;BR /&gt;
  Region1='TEST Division' ;&lt;BR /&gt;
  RegLen = length(Region1) ;&lt;BR /&gt;
&lt;BR /&gt;
  if substr(Region1,RegLen-7,8) = "Division" then&lt;BR /&gt;
  Region2 = cat(Region1," Support") ;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Contents of dataset test:&lt;BR /&gt;
&lt;BR /&gt;
Region1             RegLen        Region2&lt;BR /&gt;
TEST Division            13        Test Division Support</description>
      <pubDate>Thu, 22 Jan 2009 12:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-Substr-function/m-p/70781#M20382</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-22T12:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Substr function</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Problem-with-Substr-function/m-p/70782#M20383</link>
      <description>Worked out what the problem is now.&lt;BR /&gt;
&lt;BR /&gt;
Some of the values for Region1 are less than 7 characters long and this is where was falling down.&lt;BR /&gt;
&lt;BR /&gt;
Simple error, bit took hours to work out!!!!</description>
      <pubDate>Thu, 22 Jan 2009 12:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Problem-with-Substr-function/m-p/70782#M20383</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-22T12:50:01Z</dc:date>
    </item>
  </channel>
</rss>

