<?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 Pull out last 8 charcters of a string in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144464#M38396</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 character variables with recoreds of different lengths like 8,9,10,11,12,13,13.... i want to write a code in such way that i want to pull out only last 8 charcters of that variable....only last 8 charaters irrespective of the varaible lenght.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Jul 2014 13:20:30 GMT</pubDate>
    <dc:creator>rakeshvvv</dc:creator>
    <dc:date>2014-07-31T13:20:30Z</dc:date>
    <item>
      <title>Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144464#M38396</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 character variables with recoreds of different lengths like 8,9,10,11,12,13,13.... i want to write a code in such way that i want to pull out only last 8 charcters of that variable....only last 8 charaters irrespective of the varaible lenght.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 13:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144464#M38396</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2014-07-31T13:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144465#M38397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;rakeshvvv,&lt;/P&gt;&lt;P&gt;You did not indicate if you wanted to keep trailing blanks.&amp;nbsp; If so, you do not need the trim, left or strip functions.&amp;nbsp; Use the reverse function, grab the first 8 characters of the reversed value using the substring function; then reverse the result of the substring.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 13:26:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144465#M38397</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-07-31T13:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144466#M38398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Whilst I completely agree with the answer to the question, I would want to check what type of data he is dealing with as just chopping off any 8 chars from the end seems a bit random.&amp;nbsp; Normally you would want to have some kind of pattern indicator, i.e. all records have id or XYX-yyyyyyyy and you want the last 8.&amp;nbsp; Otherwise you could get some strange results if items are not padded as expected, there are leading/inner blanks, special characters etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 13:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144466#M38398</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-31T13:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144467#M38399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Exactly RW9!&amp;nbsp; However, that's what experienced analysts know to do.&amp;nbsp; I was answering the question posed by an audience that appears to be less experienced.&amp;nbsp; My apologies to rakesh if I assumed a skill level less experienced than you are.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 13:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144467#M38399</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-07-31T13:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144468#M38400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;substrn(s,length(s)-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;7&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, 31 Jul 2014 13:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144468#M38400</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-07-31T13:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144469#M38401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;my data looks like this and I want to have only &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;295999335&lt;/P&gt;&lt;P&gt;29599973101&lt;/P&gt;&lt;P&gt;295999333&lt;/P&gt;&lt;P&gt;2959997311&lt;/P&gt;&lt;P&gt;2959997312&lt;/P&gt;&lt;P&gt;295999735&lt;/P&gt;&lt;P&gt;2959997310&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;output should be like this....should have last 8 charaters&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;95999335&lt;/P&gt;&lt;P&gt;99973101&lt;/P&gt;&lt;P&gt;95999333&lt;/P&gt;&lt;P&gt;59997311&lt;/P&gt;&lt;P&gt;59997312&lt;/P&gt;&lt;P&gt;95999735&lt;/P&gt;&lt;P&gt;59997310&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 13:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144469#M38401</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2014-07-31T13:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144470#M38402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, whats the difference between x95999xxx and xx95999?&amp;nbsp;&amp;nbsp; Note that with your data you can strip out 295999 (e.g. tranwrd(id,"295999","")) in each instance and be left with a unique number of 3-5 digits.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 14:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144470#M38402</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-07-31T14:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144471#M38403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif';"&gt;I am dealing with a barcode number that includes the “Container number” that is one or two characters to the right of the number.&amp;nbsp; This number sometimes changes from the time to time.For improvement,&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif';"&gt;we need to remove the “Container Number”&amp;nbsp; from the barcode number (In other words, use only the 8 characters to the left of the number). &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 14:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144471#M38403</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2014-07-31T14:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144472#M38404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;rakeshvvv,&lt;/P&gt;&lt;P&gt;There are differences in functions and there are valid reasons for using one function over another.&amp;nbsp; Below are different solutions to the question you asked with the data you provided.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input fullvar one $20. ;&lt;BR /&gt;length eightlim1 eightlim2 eightlim3 two three $8;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; one&amp;nbsp; = reverse(strip(fullvar));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; two&amp;nbsp; = substr(one,1,8);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; three = reverse(two); &lt;BR /&gt;eightlim1&amp;nbsp; = reverse(substr(reverse(strip(fullvar)),1,8));&lt;BR /&gt;eightlim2&amp;nbsp; = substrn(fullvar,length(fullvar)-7);&lt;BR /&gt;eightlim3&amp;nbsp; = substr(fullvar,length(fullvar)-7);&lt;BR /&gt;datalines;&lt;BR /&gt;295999335&lt;BR /&gt;29599973101&lt;BR /&gt;295999333&lt;BR /&gt;2959997311&lt;BR /&gt;2959997312&lt;BR /&gt;295999735&lt;BR /&gt;2959997310&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=work.want;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 14:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144472#M38404</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-07-31T14:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144473#M38405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The mistake in your program is FULLVAR should be character not numeric.&amp;nbsp; The conversion to character with best12. "right justified" is the source of the differences you see in the methods.&amp;nbsp; Fix that and you get this.&lt;IMG alt="7-31-2014 10-28-35 AM.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/6920_7-31-2014 10-28-35 AM.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 15:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144473#M38405</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-07-31T15:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144474#M38406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Data_null,&lt;/P&gt;&lt;P&gt;Thank you for the correction to "input fullvar one $20." I made the mistake of thinking that the input statement acted like the format statement. "input fullvar $20 one $20." is what I should have coded.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 16:03:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144474#M38406</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-07-31T16:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144475#M38407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input string;&lt;/P&gt;&lt;P&gt;new_string=prxchange('s/.*(\d{8})/$1/',-1,strip(string));&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;295999335&lt;/P&gt;&lt;P&gt;29599973101&lt;/P&gt;&lt;P&gt;295999333&lt;/P&gt;&lt;P&gt;2959997311&lt;/P&gt;&lt;P&gt;2959997312&lt;/P&gt;&lt;P&gt;295999735&lt;/P&gt;&lt;P&gt;2959997310&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 16:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144475#M38407</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2014-07-31T16:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144476#M38408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two options:&lt;/P&gt;&lt;P&gt;1. If the var is numeric, you can just use the MOD function: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VAR8 = Mod(VAR,100000000) ;&lt;/P&gt;&lt;P&gt;2. If the var is character, use the SUBSTR function as advice by data_NULL_&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 16:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144476#M38408</guid>
      <dc:creator>asasuser</dc:creator>
      <dc:date>2014-07-31T16:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144477#M38409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could have written INPUT (fullvar one) ($20.);&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I don't understand why you are reading "ONE" at all.&amp;nbsp; There is only 1 field in the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 16:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144477#M38409</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-07-31T16:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pull out last 8 charcters of a string</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144478#M38410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In math courses, our instructors always said "show your work".&amp;nbsp; Showing my reasoning has help others. It has also allowed others to point out my mistakes. "One" is a variable that contains the value extracted from fullvar after blanks have been removed and the non-blank values have been reversed. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 17:17:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pull-out-last-8-charcters-of-a-string/m-p/144478#M38410</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2014-07-31T17:17:34Z</dc:date>
    </item>
  </channel>
</rss>

