<?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: How do I Identify Palindromes? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443636#M111008</link>
    <description>&lt;P&gt;The specification is extreme sparse. So first thing to do is creating an input-dataset and a second dataset with the expected solution. This allows you to use proc compare to verify that the generated solution matches the expected result. As soon as you have those two datasets we can think about how to solve this.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Mar 2018 05:59:42 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2018-03-08T05:59:42Z</dc:date>
    <item>
      <title>test</title>
      <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443628#M111004</link>
      <description>&lt;P&gt;question?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 02:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/test/m-p/443628#M111004</guid>
      <dc:creator>austinrousevelt</dc:creator>
      <dc:date>2018-10-04T02:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Identify Palindromes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443634#M111006</link>
      <description>&lt;P&gt;Avoid macros entirely for this problem.&amp;nbsp; Macros just automate a working process.&amp;nbsp; They are of little use unless you can program the result without using macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take a look at three functions:&amp;nbsp; REVERSE, STRIP, and UPCASE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make that four functions.&amp;nbsp; You'll also need COMPRESS.&amp;nbsp; (Once you have COMPRESS, you may not need STRIP anymore.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint:&amp;nbsp; this will be a very short program, once you apply the right tools in the right way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Able was I ere I saw Elba&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 06:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/test/m-p/443634#M111006</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-08T06:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Identify Palindromes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443635#M111007</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data pal;
     input word $25.;
     datalines;
Eye
nicola
Pop
roger
debra
sunil
veena
mirna
Noon
Level
Radar
Kayak
Rotator
john
malayalam
mark
steve
keith
naveen
jacob
Brett
Poornima
Badrinarayanan
Nepun
Parthasarathy
;
 
/*Below is the logic to check for Palindromes*/
data want;
     set pal;
     length result $30;
 
     if mod(length(strip(word)),2)=0 then
           do;
                do i=1 to divide(length(strip(word)),2);
                     if substr(lowcase(word),i,1) ne substr(lowcase(reverse(strip(word))),i,1) then
                           do;
                                result=' Not palindrome';
                                output;
                                go to next;
                           end;
                     else result='palindrome';
 
                     if i=divide(length(strip(word)),2) and result='palindrome' then
                           output;
                end;
           end;
     else if mod(length(strip(word)),2)=1 then
           do;
                do i=1 to median(1,length(strip(word)))-1;
                     if substr(lowcase(word),i,1) ne substr(lowcase(reverse(strip(word))),i,1) then
                           do;
                                result='Not palindrome';
                                output;
                                go to next;
                           end;
                     else result='palindrome';
 
                     if i=median(1,length(strip(word)))-1 and result='palindrome' then
                           output;
                end;
           end;
 
next:
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Mar 2018 05:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/test/m-p/443635#M111007</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-03-08T05:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Identify Palindromes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443636#M111008</link>
      <description>&lt;P&gt;The specification is extreme sparse. So first thing to do is creating an input-dataset and a second dataset with the expected solution. This allows you to use proc compare to verify that the generated solution matches the expected result. As soon as you have those two datasets we can think about how to solve this.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 05:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/test/m-p/443636#M111008</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-03-08T05:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Identify Palindromes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443703#M111029</link>
      <description>&lt;P&gt;I would use PROC FCMP to write a function, e.g.:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.funcs.str;
  function palindrome(str $,options $);
    str=left(str);
    options=upcase(options);
    if index(options,'I') then
      str=upcase(str);
    l=length(str);
    if l=1 then
      return(1);
    half=floor(l/2);
    if substr(str,1,half)=reverse(substr(str,l-half+1,half)) then
      return(1);
    return(0);
  endsub;
run;
options cmplib=work.funcs;
data test;
  input str $;
  p=palindrome(str,'');
  pi=palindrome(str,'i');
cards;
a
aga
aggA
aggb
;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Mar 2018 10:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/test/m-p/443703#M111029</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-03-08T10:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Identify Palindromes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443739#M111037</link>
      <description>&lt;P&gt;It is more like Computer Science student's question. Do you major CS ?&lt;/P&gt;
&lt;P&gt;And I highly suggest to use REVERSE() proposed by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
x="Able was I ere I saw Elba Hint:  this will be a very short program, once you apply the right tools in the right way";
do i=1 to length(x);
 do j=i+1 to length(x);
   temp=substr(x,i,j-i+1); 
   if temp=strip(reverse(temp)) and length(temp)&amp;gt;4 
   /* 4 is the Palindromes's least length, you could change it.*/
   then put 'Found: ' temp=;
 end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Mar 2018 13:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/test/m-p/443739#M111037</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-03-08T13:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Identify Palindromes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443740#M111038</link>
      <description>&lt;P&gt;If you want case insensitive, put UPCASE() around it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   if upcase(temp)=upcase(strip(reverse(temp))) and length(temp)&amp;gt;4 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Mar 2018 13:21:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/test/m-p/443740#M111038</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-03-08T13:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Identify Palindromes?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/test/m-p/443813#M111064</link>
      <description>&lt;P&gt;This is fun. I've augmented&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;'s approach to add case sensitive/insensitive checks, and also eliminate word spaces/punctuation from affecting the result.&amp;nbsp; After all...&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;A&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;palindrome&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;is a&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;word&lt;/STRONG&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;phrase&lt;/STRONG&gt;&lt;SPAN&gt;, number or sequence of&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;words&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;that reads the same backwards as forwards. Punctuation and&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;spaces&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;between the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;words&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;or lettering is allowed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  x="Able was I ere I saw Elba Hint:  this will be a very short program, once you apply the right tools in the right way";
  /* 4 is the Palindromes's least length, you could change it.*/
  min = 4;
  do i=1 to length(x);
    do j=i+1 to length(x);
      original = substr(x,i,j-i+1);
      temp=compress(original,,'ka');
      temp_ci=upcase(compress(original,,'ka'));
      if length(original) &amp;gt;= min then
        do;
          if temp=strip(reverse(temp)) then
            put 'Case sensitive: ' original=;
          if temp_ci = strip(reverse(temp_ci)) then
            put 'Case insensitive: ' original=;
        end;
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;I'll bet that more improvements are possible.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Mar 2018 16:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/test/m-p/443813#M111064</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-03-08T16:25:03Z</dc:date>
    </item>
  </channel>
</rss>

