<?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 Proc SQL Substring of a numeric variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169194#M264109</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking to include a substring on my query but it wont work and I get this error message -&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ERROR: Function SUBSTR requires a character expression as argument 1.&lt;/P&gt;
&lt;P&gt;Code -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table work.risk as &lt;BR /&gt;select&lt;BR /&gt;SUBSTR(account_number, 2, 9) as acc,&lt;BR /&gt;from &lt;BR /&gt;rmort.c201410_new;&lt;BR /&gt;quit;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2016 20:56:08 GMT</pubDate>
    <dc:creator>anonymous_user</dc:creator>
    <dc:date>2016-10-17T20:56:08Z</dc:date>
    <item>
      <title>Proc SQL Substring of a numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169194#M264109</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking to include a substring on my query but it wont work and I get this error message -&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ERROR: Function SUBSTR requires a character expression as argument 1.&lt;/P&gt;
&lt;P&gt;Code -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table work.risk as &lt;BR /&gt;select&lt;BR /&gt;SUBSTR(account_number, 2, 9) as acc,&lt;BR /&gt;from &lt;BR /&gt;rmort.c201410_new;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 20:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169194#M264109</guid>
      <dc:creator>anonymous_user</dc:creator>
      <dc:date>2016-10-17T20:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169195#M264110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;account_number seems to be numeric.&lt;/P&gt;&lt;P&gt;Try substr(put(account_number,z10.),2,9)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Nov 2014 12:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169195#M264110</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-11-13T12:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169196#M264111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SUBSTR is valid only for character variables NOT for numeric. Try with SUBSTRN function like below for numeric variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;a=1234567;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;new_a=substrn(a,3,2);&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Nov 2014 12:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169196#M264111</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-11-13T12:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169197#M264112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I guess right your &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;account_number&lt;/SPAN&gt; is numeric variable.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px; background-color: #ffffff;"&gt;SUBSTR(put(account_number,best32. -L), 2, 9) as acc,&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Nov 2014 12:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169197#M264112</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-11-13T12:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Substring of a numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169198#M264113</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;If I guess right your &lt;SPAN&gt;account_number&lt;/SPAN&gt; is numeric variable.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SUBSTR(put(account_number,best32. -L), 2, 9) as acc,&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi.&amp;nbsp; If Xia is correct in that ACCOUNT_NUMBER is numeric, you could also try a CAT function to temporarily use ACCOUNT_NUMBER as a character variable ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input account_number;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;123&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;1234&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;12345&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;123456&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;1234567&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;12345678&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;123456789&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;1234567890&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;create table want as &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;select substr(cat(account_number), 2, 9) as acc&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;from have;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; acc&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 23&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 234&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 2345&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp; 23456&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; 234567&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp; 2345678&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp; 23456789&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 234567890&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2016 20:56:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169198#M264113</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2016-10-17T20:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169199#M264114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS doen't seem to think like humans with their PUT and INPUT notation &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, 13 Nov 2014 17:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/169199#M264114</guid>
      <dc:creator>AminB</dc:creator>
      <dc:date>2014-11-13T17:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Substring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/301075#M264115</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having the same error, different query, do you know what is wrong with it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(SERIES): data tempsas.GDPxInd_pub_total_emp;&lt;BR /&gt;MPRINT(SERIES): set tempsas.Published_GDPxInd_Employment;&lt;BR /&gt;MPRINT(SERIES): where trim(left(line)) = "2";&lt;BR /&gt;ERROR: Function LEFT requires a character expression as argument 1.&lt;BR /&gt;SYMBOLGEN: Macro variable IOYEAR resolves to 2014&lt;BR /&gt;MPRINT(SERIES): BEA_Pub_Total_Emp = y2014;&lt;BR /&gt;MPRINT(SERIES): keep BEA_Pub_Total_Emp;&lt;BR /&gt;MPRINT(SERIES): run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Sep 2016 17:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Substring-of-a-numeric-variable/m-p/301075#M264115</guid>
      <dc:creator>Afor910327</dc:creator>
      <dc:date>2016-09-27T17:03:55Z</dc:date>
    </item>
  </channel>
</rss>

