<?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 Numeric data-SCAN/SUBSTR in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686732#M208440</link>
    <description>&lt;P&gt;When you want to show us a log please copy the text from the log and then on the forum open a box using the &amp;lt;/&amp;gt; icon and paste the text.&lt;/P&gt;
&lt;P&gt;It is much easier to copy/paste code and highlight or make corrections to the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the invalid data type messages is showing "invalid numeric data :"&lt;/P&gt;
&lt;P&gt;In the SUBSTR function if there is a third parameter it is the length of a string : Substr(var, 1,3)&amp;nbsp; &amp;lt;= the 3 is the number of characters. So Substr(var,1,":") the colon is not a number, an expression returning a number or a string that could be converted to a number "3" would work though is poor practice.&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>Fri, 25 Sep 2020 15:23:39 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-09-25T15:23:39Z</dc:date>
    <item>
      <title>Invalid Numeric data-SCAN/SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686726#M208436</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am new to SAS Programming and using SAS 9.4. Can someone help me understand the below error and the logic?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have &lt;STRONG&gt;Startdate (D)&lt;/STRONG&gt; mentioned as in following pattern&lt;STRONG&gt; (partial dates)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;01:unk:2010:12:null:null&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have run the attached code which displays a note&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'Invalid numeric data ':' at line 141 column 21'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'Invalid third argument to function SUBSTR at line 141 column 9'.&amp;nbsp;&lt;/STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="IMG_20200925_200747.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49795iF51507807581AD0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="IMG_20200925_200747.jpg" alt="IMG_20200925_200747.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 15:09:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686726#M208436</guid>
      <dc:creator>Kairali</dc:creator>
      <dc:date>2020-09-25T15:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Numeric data-SCAN/SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686729#M208438</link>
      <description>&lt;P&gt;Your error message:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;'Invalid third argument to function SUBSTR at line 141 column 9'.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code @ line 141 is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(D, 1, ':') = '01';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0uev77ebdwy90n1rsd7hwjd2qc3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;SUBSTR&lt;/A&gt; function uses a different format:&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="xisDoc-keyword"&gt;SUBSTR&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;&lt;A tabindex="0" title="“variable”" href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0uev77ebdwy90n1rsd7hwjd2qc3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1d5uigjrx21uon1jun3qyles9qj" data-docset-id="lefunctionsref" data-docset-version="9.4" data-original-href="p0uev77ebdwy90n1rsd7hwjd2qc3.htm#n1d5uigjrx21uon1jun3qyles9qj"&gt;variable&lt;/A&gt;&lt;/EM&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;&lt;A tabindex="0" title="“position”" href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0uev77ebdwy90n1rsd7hwjd2qc3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p0byvokit3uhiun1pr9m8r4cxuui" data-docset-id="lefunctionsref" data-docset-version="9.4" data-original-href="p0uev77ebdwy90n1rsd7hwjd2qc3.htm#p0byvokit3uhiun1pr9m8r4cxuui"&gt;position&lt;/A&gt;&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="xisDoc-optional"&gt;&amp;lt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;&lt;A tabindex="0" title="“length”" href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0uev77ebdwy90n1rsd7hwjd2qc3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p1mjn7wvi8ccxdn1d95fagehx8uq" data-docset-id="lefunctionsref" data-docset-version="9.4" data-original-href="p0uev77ebdwy90n1rsd7hwjd2qc3.htm#p1mjn7wvi8ccxdn1d95fagehx8uq"&gt;length&lt;/A&gt;&lt;/EM&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;)=&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;&lt;A class="" tabindex="0" title="“characters-to-replace”" href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0uev77ebdwy90n1rsd7hwjd2qc3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p1qps5gf3j68o6n0z4vcl567xlin" data-docset-id="lefunctionsref" data-docset-version="9.4" data-original-href="p0uev77ebdwy90n1rsd7hwjd2qc3.htm#p1qps5gf3j68o6n0z4vcl567xlin"&gt;characters-to-replace&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I would suggest looking into TRANWRD instead of SUBSTR here which allows you a little more control of what replacing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(d, 1, 2) = '01'&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For data validation for a field like this I'd break each component down into it's parts, evaluate it and then recombine them back into a date using DHMS or MDY() functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/349165"&gt;@Kairali&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am new to SAS Programming and using SAS 9.4. Can someone help me understand the below error and the logic?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have &lt;STRONG&gt;Startdate (D)&lt;/STRONG&gt; mentioned as in following pattern&lt;STRONG&gt; (partial dates)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;01:unk:2010:12:null:null&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I have run the attached code which displays a note&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;'Invalid numeric data ':' at line 141 column 21'&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;'Invalid third argument to function SUBSTR at line 141 column 9'.&amp;nbsp;&lt;/STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="IMG_20200925_200747.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49795iF51507807581AD0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="IMG_20200925_200747.jpg" alt="IMG_20200925_200747.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 15:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686729#M208438</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-09-25T15:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Numeric data-SCAN/SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686732#M208440</link>
      <description>&lt;P&gt;When you want to show us a log please copy the text from the log and then on the forum open a box using the &amp;lt;/&amp;gt; icon and paste the text.&lt;/P&gt;
&lt;P&gt;It is much easier to copy/paste code and highlight or make corrections to the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the invalid data type messages is showing "invalid numeric data :"&lt;/P&gt;
&lt;P&gt;In the SUBSTR function if there is a third parameter it is the length of a string : Substr(var, 1,3)&amp;nbsp; &amp;lt;= the 3 is the number of characters. So Substr(var,1,":") the colon is not a number, an expression returning a number or a string that could be converted to a number "3" would work though is poor practice.&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>Fri, 25 Sep 2020 15:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686732#M208440</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-25T15:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Numeric data-SCAN/SUBSTR</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686926#M208499</link>
      <description>Thank you! I had missed that.</description>
      <pubDate>Sat, 26 Sep 2020 14:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Numeric-data-SCAN-SUBSTR/m-p/686926#M208499</guid>
      <dc:creator>Kairali</dc:creator>
      <dc:date>2020-09-26T14:14:55Z</dc:date>
    </item>
  </channel>
</rss>

