<?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: Reverse Substr in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198265#M49550</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if the lenght of the var is 10 then we have to take the characters from 8,9 and 10th position.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;substr(var, starting position, no of characters)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to get the starting position we will do length(var) - 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want the last 5 characters then the same will be length(var)-4&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Jul 2015 14:05:54 GMT</pubDate>
    <dc:creator>MadhuKorni</dc:creator>
    <dc:date>2015-07-08T14:05:54Z</dc:date>
    <item>
      <title>Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198258#M49543</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;Can someone help in the extracting last three characters of a string...irrespective of the length of the string i should extract last 3 three into new variable......I am attaching the sample number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;32-015-10101&lt;/P&gt;&lt;P&gt;32-015-11201&lt;/P&gt;&lt;P&gt;32-015-11501&lt;/P&gt;&lt;P&gt;32-015-11502&lt;/P&gt;&lt;P&gt;32-015-11503&lt;/P&gt;&lt;P&gt;32-015-11504&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;output should like this.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;101&lt;/P&gt;&lt;P&gt;201&lt;/P&gt;&lt;P&gt;501&lt;/P&gt;&lt;P&gt;502&lt;/P&gt;&lt;P&gt;503&lt;/P&gt;&lt;P&gt;504&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 13:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198258#M49543</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2015-07-08T13:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198259#M49544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if you want the last 3 in character or numeric, but this should pull out the last 3 regardless of the length of the variable:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newvar=substr(oldvar,length(oldvar)-2,3);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 13:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198259#M49544</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2015-07-08T13:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198260#M49545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the substring function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var2=substr(var1,length(var1)-2,3);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 13:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198260#M49545</guid>
      <dc:creator>viveklanka</dc:creator>
      <dc:date>2015-07-08T13:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198261#M49546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;it does help..can you let me know what does -2 mean in the code....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 14:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198261#M49546</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2015-07-08T14:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198262#M49547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if you want the result as character then &lt;/P&gt;&lt;P&gt;reqvar = substr(var,length(var)-2,3);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want the result as numeric then&lt;/P&gt;&lt;P&gt;reqvar = input(&lt;SPAN style="font-size: 13.3333330154419px;"&gt; substr(var,length(var)-2,3),best3.);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 14:02:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198262#M49547</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2015-07-08T14:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198263#M49548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It just means to take the entire length of the variable, and then go back 2 spots from the end of the length.&amp;nbsp; Then you take the next 3 values in the string.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 14:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198263#M49548</guid>
      <dc:creator>dcruik</dc:creator>
      <dc:date>2015-07-08T14:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198264#M49549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It means that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length(var)-2&amp;nbsp;&amp;nbsp; this means from the length of the variable you are going 2 places prior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for ex: 32-015-10101&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length (var)= 12&lt;/P&gt;&lt;P&gt;length(var)-1=11&lt;/P&gt;&lt;P&gt;length(var)-2=10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from 10th position you want to take three characters, which will give you the last 3 chars that is why its -2&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 14:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198264#M49549</guid>
      <dc:creator>viveklanka</dc:creator>
      <dc:date>2015-07-08T14:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198265#M49550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if the lenght of the var is 10 then we have to take the characters from 8,9 and 10th position.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;substr(var, starting position, no of characters)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to get the starting position we will do length(var) - 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you want the last 5 characters then the same will be length(var)-4&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 14:05:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198265#M49550</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2015-07-08T14:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198266#M49551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can use &lt;SPAN style="font-size: 13.3333330154419px;"&gt;reverse function&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;newvar=substr(reverse(strip(oldvar)),1,3); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 14:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198266#M49551</guid>
      <dc:creator>saidi</dc:creator>
      <dc:date>2015-07-08T14:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198267#M49552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you use reverse function then the entire string will be reversed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you take the first 3 characters from the result then we will get the result which is reverse to the actual req output&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the result will be like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;101&lt;/P&gt;&lt;P&gt;102&lt;/P&gt;&lt;P&gt;105&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but he wants the result like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;101&lt;/P&gt;&lt;P&gt;201&lt;/P&gt;&lt;P&gt;501&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So again we have to apply reverse for the final output to get the desired output&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jul 2015 14:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/198267#M49552</guid>
      <dc:creator>MadhuKorni</dc:creator>
      <dc:date>2015-07-08T14:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse Substr</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/355396#M64179</link>
      <description>thanks that worked perfectly!</description>
      <pubDate>Tue, 02 May 2017 20:51:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reverse-Substr/m-p/355396#M64179</guid>
      <dc:creator>desrcam</dc:creator>
      <dc:date>2017-05-02T20:51:22Z</dc:date>
    </item>
  </channel>
</rss>

