<?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: using substring in proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157071#M41181</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As long as it has the 10 values in the field I need, otherwise the field is useless&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Jun 2014 17:18:16 GMT</pubDate>
    <dc:creator>podarum</dc:creator>
    <dc:date>2014-06-26T17:18:16Z</dc:date>
    <item>
      <title>using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157065#M41175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm tring to substring a character field (eg. 00000000012345678912) in proc sql and and need to convert it to numeric.&amp;nbsp; I only need the 1234567891 from the field (position 10 for 11 fields).&amp;nbsp; I'm using this format :&lt;/P&gt;&lt;P&gt;cast((substr( AR_NO,10,11)) as integer) as AR_NO_SUB , but getting an error (below)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;ERROR: Teradata row not delivered (trget): Overflow occurred computing an expression involving DB.AR_NO.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;if I do&lt;/SPAN&gt; cast((substr( AR_NO,&lt;STRONG&gt;4,11&lt;/STRONG&gt;)) as integer) as AR_NO_SUB i get 69267, but&lt;/P&gt;&lt;P&gt;if I do cast((substr( AR_NO,&lt;STRONG&gt;5,11&lt;/STRONG&gt;)) as integer) as AR_NO_CUB I get the error as above in red.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankss for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 16:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157065#M41175</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2014-06-26T16:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157066#M41176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You probably have some AR_NO that are not long enough. Check the maximum and minimum length of the field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 16:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157066#M41176</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-26T16:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157067#M41177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure, can we use cast function in proc sql?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 16:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157067#M41177</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-26T16:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157068#M41178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good question.. but I guess I should of mentioned that I need to connect to Teradata first, since it is data from the Enterprise Datawarehouse. So this I'm actually doing in Teradata SQL embedded in proc sql.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 16:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157068#M41178</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2014-06-26T16:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157069#M41179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is the correct way of doing it&lt;/P&gt;&lt;P&gt;max(length(a.AR_NO)) as max, min(length(a.AR_NO)) as min, then the results are 20 max and 1 min.. Knowing this info, is there a fix to get this working ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 17:01:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157069#M41179</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2014-06-26T17:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157070#M41180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;well, what results do you expect when the length is less than 11, or 1 for example &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 17:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157070#M41180</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-26T17:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157071#M41181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As long as it has the 10 values in the field I need, otherwise the field is useless&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 17:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157071#M41181</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2014-06-26T17:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157072#M41182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My question would be why is the length less than what you expect.&lt;/P&gt;&lt;P&gt;To deal with it from a programming perspective, you can use a case statement.&lt;/P&gt;&lt;P&gt;case when length(ar_no)&amp;gt;20 then cast ....&lt;/P&gt;&lt;P&gt;else Null end as new_var&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 17:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157072#M41182</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-26T17:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157073#M41183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The question is an indication you have an inconsistent dwh.&amp;nbsp; Try to have it solved by the dwh guys first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 18:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157073#M41183</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-06-26T18:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157074#M41184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if this can solve the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select AR_NO,input(substr( AR_NO,10,11),best.) as integer as AR_NO_SUB from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 18:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157074#M41184</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-26T18:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157075#M41185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is very helpful, thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jun 2014 18:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/157075#M41185</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2014-06-26T18:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: using substring in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/549803#M74491</link>
      <description>&lt;P&gt;If you are using Teradata and need to convert an attribute that is a character-type to a numeric-type, let me suggest that you do the work using "explicit SQL" in the native Teradata SQL dilect, and not in SAS-SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The example below shows the steps I use.&amp;nbsp; Only the last is truly needed.&amp;nbsp; The regex replace function removed any remaining non-numeric characters, like any potential nonprinting characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SELECT &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '00000000012345678912'&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , TRIM( LEADING '0' FROM '00000000012345678912' )&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , REGEXP_REPLACE( TRIM( LEADING '0' FROM '00000000012345678912' ), '[^0-9]+','',1,0,'i')&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , CAST( REGEXP_REPLACE( TRIM( LEADING '0' FROM '00000000012345678912' ), '[^0-9]+','',1,0,'i') AS BIGINT )&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may be able to use the INTEGER datatype. Instead of a BIGINT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The number in your example (12,345,678,912) is a BIGINT, a 64-bit (8-byte) signed integer.&lt;BR /&gt;Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 20:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/using-substring-in-proc-sql/m-p/549803#M74491</guid>
      <dc:creator>cal4gORl3ndU</dc:creator>
      <dc:date>2019-04-09T20:54:47Z</dc:date>
    </item>
  </channel>
</rss>

