<?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: Trying to find reverse of string Without reverse function. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619866#M182076</link>
    <description>&lt;P&gt;Great point sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;I wonder &lt;STRONG&gt;why anybody would want to do it&lt;/STRONG&gt; without using the reverse function, unless it is a challenge&amp;nbsp;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would share an experience from a failed interview of mine The interviewer had the attitude that he knew everything and quizzed me on the syntax, which I failed to answer. Basically that event was just an ego event. I do like competition and being competitive but didn't quite expect that &lt;EM&gt;in an interview&lt;/EM&gt; to show off &lt;EM&gt;"I know more and am better than you" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/EM&gt; Funnily enough, that person called his mate to bully me saying&lt;EM&gt; " have i been told whether it's a SAS interview"&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Of course no offense to OP and I am sure here in a forum is perhaps truly a challenge. Nonetheless, I was expressing my opinion.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jan 2020 16:50:07 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-01-24T16:50:07Z</dc:date>
    <item>
      <title>Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619848#M182062</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Trying to get reverse of these records.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Input dataset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data temp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;input list $50.;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cards;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;hellothere&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thankyou&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;goodbye&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;welcome&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Tried something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;set temp;&lt;BR /&gt;l = length(list);&lt;BR /&gt;format list1 $50.&lt;BR /&gt;list1 = '';&lt;BR /&gt;do i= 1 to l;&lt;BR /&gt;list1 = cats(list1,substr(list,i,-1));&lt;/P&gt;&lt;P&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 16:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619848#M182062</guid>
      <dc:creator>Anmolkhandelwal</dc:creator>
      <dc:date>2020-01-24T16:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619855#M182068</link>
      <description>&lt;P&gt;What exactly are you trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A beginning string of "hellothere" followed by 40 blanks, reversed would normally be 40 blanks followed by "erehtolleh".&amp;nbsp; Is that your goal, or are you trying to get "erehtolleh" followed by 40 blanks?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 16:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619855#M182068</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-01-24T16:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619856#M182069</link>
      <description>&lt;P&gt;I think this should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	set temp;
	length newword $100; /*create a new column with a length of 100*/
	newword=""; /*Start the value of the new column as a blank*/
	l = length(list); /*find the length of the word*/
	do i=l to 1 by -1; /*start from the last character and go to the first*/
		letter=char(list,i); /*get the last letter, go down by one each loop*/
		newword=cats(newword,letter); /*concatenate every letter throughout the loop*/
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 16:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619856#M182069</guid>
      <dc:creator>Panagiotis</dc:creator>
      <dc:date>2020-01-24T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619857#M182070</link>
      <description>&lt;P&gt;I didn't think about what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;brought up. Mine program just reverses the word.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 16:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619857#M182070</guid>
      <dc:creator>Panagiotis</dc:creator>
      <dc:date>2020-01-24T16:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619861#M182072</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152214"&gt;@Panagiotis&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder why anybody would want to do it without using the reverse function, unless it is a challenge: Write an algoritm that preserves blanks, not only leading and trailing, but also embedded in the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that excludes CAT-functions and also trim + concatenation and calls for the substr(left of) function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test;
	text = '      this is a      string ';
	revtext = text;
	imax = length(text||'.')-1;
	do i = imax to 1 by -1;
	 	ri = imax - i + 1;
		substr(revtext,ri,1) = substr(text,i,1);
	end;

	utext= '/' || text || '/';
	urevtext = '/' || revtext || '/';
	put utext;
	put urevtext;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 16:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619861#M182072</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2020-01-24T16:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619866#M182076</link>
      <description>&lt;P&gt;Great point sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;I wonder &lt;STRONG&gt;why anybody would want to do it&lt;/STRONG&gt; without using the reverse function, unless it is a challenge&amp;nbsp;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would share an experience from a failed interview of mine The interviewer had the attitude that he knew everything and quizzed me on the syntax, which I failed to answer. Basically that event was just an ego event. I do like competition and being competitive but didn't quite expect that &lt;EM&gt;in an interview&lt;/EM&gt; to show off &lt;EM&gt;"I know more and am better than you" &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/EM&gt; Funnily enough, that person called his mate to bully me saying&lt;EM&gt; " have i been told whether it's a SAS interview"&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Of course no offense to OP and I am sure here in a forum is perhaps truly a challenge. Nonetheless, I was expressing my opinion.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 16:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619866#M182076</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-24T16:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619867#M182077</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12887"&gt;@ErikLund_Jensen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;&amp;nbsp; and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152214"&gt;@Panagiotis&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder why anybody would want to do it without using the reverse function, unless it is a challenge: Write an algoritm that preserves blanks, not only leading and trailing, but also embedded in the string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In my case this was the first assignment in an assembler programming class.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructor assigned reversing a numeric value expecting loops and modular arithmetic. I used buffer operations that would reverse any string and got extra credit for a more generic approach.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2020 16:51:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619867#M182077</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-24T16:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619900#M182091</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269825"&gt;@Anmolkhandelwal&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If only the REVERSE &lt;EM&gt;function&lt;/EM&gt; is prohibited, why not take the rare opportunity to use the&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p0ti0qkwdebezvn1jp7z10rcdblc.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;$REVERS&lt;EM&gt;w&lt;/EM&gt;.&lt;/A&gt;&amp;nbsp;or&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p1fsdphpsd0h53n1b6rvrvkz1405.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;$REVERJ&lt;EM&gt;w&lt;/EM&gt;.&lt;/A&gt;&amp;nbsp;&lt;EM&gt;format&lt;/EM&gt;? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set temp;
list=put(list,$revers50.); /* or $reverj50. to preserve the leading (formerly trailing) blanks */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jan 2020 18:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619900#M182091</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-01-24T18:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to find reverse of string Without reverse function.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619967#M182109</link>
      <description>&lt;P&gt;Some fun with APP and Arrays combined&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
input list $50.;
cards;
hellothere
thankyou
goodbye
welcome
;
run;

data want;
 set temp;
 length want $50;
 array t(50)$1 ;
 call pokelong(list,addrlong(t(1)),50);
 array u t50-t1;
 want= cats(of u(*));
 drop t:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Jan 2020 00:50:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-find-reverse-of-string-Without-reverse-function/m-p/619967#M182109</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-01-25T00:50:42Z</dc:date>
    </item>
  </channel>
</rss>

