<?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: Reversing string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243291#M45226</link>
    <description>&lt;P&gt;Several items to note:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;As was already mentioned, you don't need RETAIN at all.&lt;/LI&gt;
&lt;LI&gt;OUTPUT should also be removed.&amp;nbsp; Using it creates multiple observations from the original single observation.&lt;/LI&gt;
&lt;LI&gt;CATX is the wrong function.&amp;nbsp; It looks like it should be CATS instead.&lt;/LI&gt;
&lt;LI&gt;Your original value for NAME does not contain any trailing blanks.&amp;nbsp; This becomes a much trickier problem if trailing blanks are involved.&lt;/LI&gt;
&lt;LI&gt;The STRIP function isn't doing anything and therefore should be removed.&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Wed, 13 Jan 2016 18:26:16 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-01-13T18:26:16Z</dc:date>
    <item>
      <title>Reversing string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243284#M45222</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm a SAS newbie. I was trying out something to reverse the string. I know there is SAS function REVERSE but I want to write my own code for fun &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;here is my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data try;&lt;BR /&gt;name="Bellevue";&lt;BR /&gt;length revname $ 20;&lt;BR /&gt;retain revname;&lt;BR /&gt;do i= length(name) to 1 by -1;&lt;BR /&gt;revname=catx(revname, strip(substr(name, i, 1)));&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but if you run the code, I'm not getting string though I've used retain statement. Whats going wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 18:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243284#M45222</guid>
      <dc:creator>Neeta</dc:creator>
      <dc:date>2016-01-13T18:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243288#M45225</link>
      <description>&lt;P&gt;Chk this old thread&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Reverse-any-string-without-using-function-Reverse/m-p/182375#U182375" target="_self"&gt;Reverse any string without using function&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;You do not need retain for that....&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 18:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243288#M45225</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-13T18:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243291#M45226</link>
      <description>&lt;P&gt;Several items to note:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;As was already mentioned, you don't need RETAIN at all.&lt;/LI&gt;
&lt;LI&gt;OUTPUT should also be removed.&amp;nbsp; Using it creates multiple observations from the original single observation.&lt;/LI&gt;
&lt;LI&gt;CATX is the wrong function.&amp;nbsp; It looks like it should be CATS instead.&lt;/LI&gt;
&lt;LI&gt;Your original value for NAME does not contain any trailing blanks.&amp;nbsp; This becomes a much trickier problem if trailing blanks are involved.&lt;/LI&gt;
&lt;LI&gt;The STRIP function isn't doing anything and therefore should be removed.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Wed, 13 Jan 2016 18:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243291#M45226</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-13T18:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243295#M45228</link>
      <description>&lt;P&gt;Good points from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;. Regarding trailing blanks, I don't think they would be desired as leading blanks in variable REVNAME (and they wouldn't occur as such with the current approach). But if they were desired, one could create them easily with a final&amp;nbsp;&lt;FONT face="courier new,courier"&gt;revname=right(revname);&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 18:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243295#M45228</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-13T18:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243297#M45229</link>
      <description>&lt;P&gt;Retain is for keeping values as you move down a column or through the data set. Since you're not stepping through a traditional data set and operating on the same line the Retain function isn't required. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2016 18:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243297#M45229</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-13T18:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Reversing string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243399#M45261</link>
      <description>&lt;P&gt;Here is another approach, using a temporary array&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data try;
length name revname $ 20;
array c{100} $1 _temporary_;
do name = "Bellevue", "stressed";
    call missing(of c{*});
    do i= 1 to length(name);
        c{dim(c)-i+1} = char(name,i);
        end;
    revname=cats(of c{*});
    output;
    end;
drop i;
run;

proc print noobs data=try; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2016 03:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reversing-string/m-p/243399#M45261</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-01-14T03:52:21Z</dc:date>
    </item>
  </channel>
</rss>

