<?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: Irrespective of Length, remove numarics on end of the data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182516#M34749</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;Well, there are several options here:&lt;/P&gt;&lt;P&gt;Perl Regular expressions - This is probably the main options for string matching/replacing, however I foget the exact terminology now (prxparse, prxmatch etc)&lt;/P&gt;&lt;P&gt;Substr:&amp;nbsp; Assuming the first number is zero (or a pattern) then you can do: substr(text,1,index(text,"0")-1);&lt;/P&gt;&lt;P&gt;String array: Just for fun this one:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do I=1 to length(text);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if substr(text,i,1) in ('0','1','2',...) then substr(text,i,1)=" ";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Jul 2014 08:16:16 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2014-07-17T08:16:16Z</dc:date>
    <item>
      <title>Irrespective of Length, remove numarics on end of the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182515#M34748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; Hi All,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;And Thank you for quick Response.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;data have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;input error $200.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;1 LLLL MMMMM NNNN Missing0048165&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;2 LLLL MMMMM NNNN Missing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;3 AAAAAA BBBBB CCCCCCCC segment Required0048158&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;4 AAAAAA BBBBB CCCCCCCC segment Required&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;5 XXXX YYYYYY ZZZZZZ (Required) Missing0000047&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;6 XXXX YYYYYY ZZZZZZ (Required) Missing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;From here -&amp;nbsp; if data is ending with number need to remove the number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;if number is available on end of the data its not same and having differnt length&lt;/STRONG&gt;&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;output like&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;1 LLLL MMMMM NNNN Missing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;2 LLLL MMMMM NNNN Missing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;3 AAAAAA BBBBB CCCCCCCC segment Required&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;4 AAAAAA BBBBB CCCCCCCC segment Required&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;5 XXXX YYYYYY ZZZZZZ (Required) Missing&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;6 XXXX YYYYYY ZZZZZZ (Required) Missing&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 07:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182515#M34748</guid>
      <dc:creator>sas_lak</dc:creator>
      <dc:date>2014-07-17T07:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Irrespective of Length, remove numarics on end of the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182516#M34749</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;Well, there are several options here:&lt;/P&gt;&lt;P&gt;Perl Regular expressions - This is probably the main options for string matching/replacing, however I foget the exact terminology now (prxparse, prxmatch etc)&lt;/P&gt;&lt;P&gt;Substr:&amp;nbsp; Assuming the first number is zero (or a pattern) then you can do: substr(text,1,index(text,"0")-1);&lt;/P&gt;&lt;P&gt;String array: Just for fun this one:&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do I=1 to length(text);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if substr(text,i,1) in ('0','1','2',...) then substr(text,i,1)=" ";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 08:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182516#M34749</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-17T08:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Irrespective of Length, remove numarics on end of the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182517#M34750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank u RW9,&lt;/P&gt;&lt;P&gt;But small correction from your code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I dont want remove any numbers from the data, which is, data ending with numbers like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt; AAAAAA BBBBB CCCCCCCC segment &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Required0048158&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; need to remove &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;0048158&lt;/STRONG&gt;&lt;/SPAN&gt; only.(not any numbers from middle of the data)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please help me to get it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 08:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182517#M34750</guid>
      <dc:creator>sas_lak</dc:creator>
      <dc:date>2014-07-17T08:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Irrespective of Length, remove numarics on end of the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182518#M34751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would go for a regular expression, see below:&lt;/P&gt;&lt;P&gt;The \d idenifies digits, the + matches one or more times, the $ matches the position at the end of the input string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is important to trim the string first&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;truncover&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; error &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$200.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;1 LLLL MMMMM NNNN Missing0048165a&lt;BR /&gt;2 LLLL MMMMM NNNN Missing&lt;BR /&gt;3 AAAAAA BBBBB CCCCCCCC segment Required0048158&lt;BR /&gt;4 AAAAAA BBBBB CCCCCCCC segment Required&lt;BR /&gt;5 XXXX YYYYYY ZZZZZZ (Required) Missing0000047&lt;BR /&gt;6 XXXX YYYYYY ZZZZZZ (Required) Missing&lt;BR /&gt;&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; want;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; digitStart = prxmatch(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"/\d+$/"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, trim(error));&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; part1 = substr(error, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, digitStart-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&amp;nbsp; part2 = substr(error, digitStart);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 08:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Irrespective-of-Length-remove-numarics-on-end-of-the-data/m-p/182518#M34751</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2014-07-17T08:37:05Z</dc:date>
    </item>
  </channel>
</rss>

