<?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: invalid third argument to function SUBSTR error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472342#M121108</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183379"&gt;@pau13rown&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have a supplementary Q: does anyone know if you can specify a 3rd argument as missing which would indicate: from the 2nd argument to the end of the string?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, just don't define a 3rd argument: &lt;SPAN&gt;substr(id3, 3)&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jun 2018 01:02:55 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2018-06-22T01:02:55Z</dc:date>
    <item>
      <title>invalid third argument to function SUBSTR error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472327#M121099</link>
      <description>&lt;P&gt;&lt;BR /&gt;Taking over code from colleague who left company.&lt;BR /&gt;Not sure I understand what the line 'else if...' is doing as I get the following error.&lt;BR /&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error" Invalid third argument to function SUBSTR&lt;BR /&gt;id2=0012312345 Pat_id=55555 Enc_type=office visit&lt;BR /&gt;region=NY id2=12312345 id=12312345 age=30 bmi 20.8 _ERROR_=1 _N_=6&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Variable id2 is text length 11:&lt;/P&gt;&lt;P&gt;id2&lt;BR /&gt;0012312345&lt;BR /&gt;0023454321&lt;BR /&gt;0034565656&lt;BR /&gt;0099912345&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;BR /&gt;data two;&lt;BR /&gt;set one (rename=(id2=id3));&lt;BR /&gt;by pat_id;&lt;BR /&gt;region='NY';&lt;/P&gt;&lt;P&gt;IF region='MN' then ID2=compress(ID3);&lt;BR /&gt;&lt;BR /&gt;Else if region='NY' then ID2=compress(put(input(substr(id3, 3, 11),11.),11.) );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;id = input(id2,15.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jun 2018 23:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472327#M121099</guid>
      <dc:creator>lam1</dc:creator>
      <dc:date>2018-06-21T23:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: invalid third argument to function SUBSTR error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472336#M121103</link>
      <description>&lt;P&gt;id3 is 10 chars long and substr 3rd argument is 11. Although length is specified as 11, thus check if it ever exceeds 10 chars, if not change to substr(id3, 3, 10)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a supplementary Q: does anyone know if you can specify a 3rd argument as missing which would indicate: from the 2nd argument to the end of the string?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 00:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472336#M121103</guid>
      <dc:creator>pau13rown</dc:creator>
      <dc:date>2018-06-22T00:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: invalid third argument to function SUBSTR error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472342#M121108</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/183379"&gt;@pau13rown&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have a supplementary Q: does anyone know if you can specify a 3rd argument as missing which would indicate: from the 2nd argument to the end of the string?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, just don't define a 3rd argument: &lt;SPAN&gt;substr(id3, 3)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 01:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472342#M121108</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-22T01:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: invalid third argument to function SUBSTR error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472343#M121109</link>
      <description>&lt;P&gt;great to know, i always tried "&lt;SPAN&gt;substr(id3, 3, )&lt;/SPAN&gt;" with a superfluous comma&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 01:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472343#M121109</guid>
      <dc:creator>pau13rown</dc:creator>
      <dc:date>2018-06-22T01:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: invalid third argument to function SUBSTR error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472344#M121110</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/176244"&gt;@lam1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;Taking over code from colleague who left company.&lt;BR /&gt;Not sure I understand what the line 'else if...' is doing as I get the following error.&lt;BR /&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Error" Invalid third argument to function SUBSTR&lt;BR /&gt;id2=0012312345 Pat_id=55555 Enc_type=office visit&lt;BR /&gt;region=NY id2=12312345 id=12312345 age=30 bmi 20.8 _ERROR_=1 _N_=6&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Variable id2 is text length 11:&lt;/P&gt;
&lt;P&gt;id2&lt;BR /&gt;0012312345&lt;BR /&gt;0023454321&lt;BR /&gt;0034565656&lt;BR /&gt;0099912345&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;BR /&gt;data two;&lt;BR /&gt;set one (rename=(id2=id3));&lt;BR /&gt;by pat_id;&lt;BR /&gt;region='NY';&lt;/P&gt;
&lt;P&gt;IF region='MN' then ID2=compress(ID3);&lt;BR /&gt;&lt;BR /&gt;Else if region='NY' then ID2=compress(put(input(substr(id3, 3, 11),11.),11.) );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id = input(id2,15.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/176244"&gt;@lam1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;That looks to me like a piece of unfinished messy code which you better re-write from scratch&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;Here region gets set to NY so below IF condition will never be true.&lt;/P&gt;
&lt;PRE&gt;region='NY';
IF region='MN' then ID2=compress(ID3);&lt;/PRE&gt;
&lt;P&gt;That looks like an attempt to convert a string of digits to a number.&lt;/P&gt;
&lt;PRE&gt;Else if region='NY' then ID2=compress(put(input(substr(id3, 3, 11),11.),11.) );
id = input(id2,15.);&lt;/PRE&gt;
&lt;P&gt;There is absolutely no need to first try and strip leading zeros from the string for such a conversion. Code as below should do.&lt;/P&gt;
&lt;PRE&gt;id=input(id3,? best32.);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 01:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/invalid-third-argument-to-function-SUBSTR-error/m-p/472344#M121110</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-06-22T01:14:58Z</dc:date>
    </item>
  </channel>
</rss>

