<?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: remove last charater and convert to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193225#M266279</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H3 style="color: #353535; font-family: Lato, sans-serif; background-color: #f0f1f2;"&gt;Code: Program&lt;/H3&gt;&lt;PRE class="sce-render" style="font-family: 'Courier New', Menlo, 'Lucida Console'; font-size: 16px;"&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;data&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;a&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string" style="color: #800080;"&gt;'123456789A'&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;b&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;input&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;compress&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;a&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string" style="color: #800080;"&gt;'kd'&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="format" style="color: #008080;"&gt;best32.&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;put&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;a&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;b&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;run&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Jul 2015 13:19:14 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-07-01T13:19:14Z</dc:date>
    <item>
      <title>remove last charater and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193223#M266277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a field which has nine numeric characters and a letter.. 123456789A. I want to remove the last character and convert the field to numberic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have te following to strip the last character ... SUBSTR(ABC,1,9)&amp;nbsp; as ABCI and have also found this to convert to numeric .. input(substr(ABCI,5),best.) as ABCII&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm still new to SAS, but can these be combined or is there another/better method to remove the last character from ABC and convert to to a numeric value?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Haydn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2015 02:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193223#M266277</guid>
      <dc:creator>Haydn</dc:creator>
      <dc:date>2015-07-01T02:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: remove last charater and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193224#M266278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;An easier way:&amp;nbsp; Don't bother to strip the last character.&amp;nbsp; Just read the first 9 digits into a numeric:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newvar = input(oldvar, 9.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, this relies on the first 9 characters always being digits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2015 13:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193224#M266278</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-07-01T13:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: remove last charater and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193225#M266279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H3 style="color: #353535; font-family: Lato, sans-serif; background-color: #f0f1f2;"&gt;Code: Program&lt;/H3&gt;&lt;PRE class="sce-render" style="font-family: 'Courier New', Menlo, 'Lucida Console'; font-size: 16px;"&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;data&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;_null_&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;a&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string" style="color: #800080;"&gt;'123456789A'&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;b&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;input&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;compress&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;a&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string" style="color: #800080;"&gt;'kd'&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="format" style="color: #008080;"&gt;best32.&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;put&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;a&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text" style="color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN class="keyword" style="color: #0000ff;"&gt;b&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="sec-keyword" style="color: #000080; font-weight: bold;"&gt;run&lt;/SPAN&gt;&lt;SPAN class="sep" style="color: black;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2015 13:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193225#M266279</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-07-01T13:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: remove last charater and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193226#M266280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;As it is a character variable, it will be left alligned and you need the first 9 characters which doesnt require to use strip.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;newvar=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;input(substr(var,1,9),9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;data Sample;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt; having='123456789A';&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;wanted&lt;/SPAN&gt;=input(substr(having,1,9),9.);&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2015 13:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193226#M266280</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2015-07-01T13:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: remove last charater and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193227#M266281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So the INPUT function might be all you need.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;num=input(char,9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if the number part might use less than 9 digits then you might need to do some more work.&amp;nbsp; If the variable is defined as length 10 then adding a RIGHT() function to move the value over so that letter is in the 9th place will work.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;num = input(right(char),9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or perhaps use substr() to make sure you only have 10 characters.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;num = input(right(substr(char,1,10)),9.) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2015 15:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193227#M266281</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-07-01T15:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: remove last charater and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193228#M266282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use this code to make it more efficient:-&lt;/P&gt;&lt;P&gt;input dataset:--&amp;gt;&lt;/P&gt;&lt;P&gt;data cont;&lt;/P&gt;&lt;P&gt;input col1 $ 10.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;123456789A&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Desired output:---&amp;gt;&lt;/P&gt;&lt;P&gt;data cont1;&lt;/P&gt;&lt;P&gt;set cont;&lt;/P&gt;&lt;P&gt;char=compress(col1,'0-9','d');&lt;/P&gt;&lt;P&gt;num=input(compress(col1,'a-z','a'),best12.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jul 2015 11:00:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-last-charater-and-convert-to-numeric/m-p/193228#M266282</guid>
      <dc:creator>Dalveer</dc:creator>
      <dc:date>2015-07-02T11:00:49Z</dc:date>
    </item>
  </channel>
</rss>

