<?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: Macro Logic to find Palindromes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444778#M111403</link>
    <description>&lt;PRE&gt;data _null_;
  set sashelp.vcolumn (where=(libname="WORK"));
  by memname;
  if first.memname then call execute('data '||strip(memname)||'; set '||strip(memname)||';');
  call execute('if strip(reverse('||strip(name)||'))=strip('||strip(name)||') then '||strip(name)||'_palindrome="Yes";');
  if last.memname then call execute(';run;');
run;
&lt;/PRE&gt;
&lt;P&gt;Will do the palindrome check for every variable in every dataset in the work library. If you just want one dataset, then update the the where clause to be:&lt;/P&gt;
&lt;P&gt;(where=(libname="WORK" and memname="TMP"))&lt;/P&gt;
&lt;P&gt;For example only does TMP in WORK library, upcase is important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Mar 2018 14:48:26 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-03-12T14:48:26Z</dc:date>
    <item>
      <title>Macro Logic to find Palindromes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444765#M111396</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to identify all palindromes within a directory. I use a proc contents and proc sort to identify the datasets within a directory, like so:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contentss data = dPath._all_ out = dFiles (keep = memname);
run; 

proc sort data = dFiles nodupkey; &lt;BR /&gt;by memname;&lt;BR /&gt;run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to identify palindromes within this directory. As it stands, the macro parameter would take in a string and reverse it. However, I would like to do this for all rows/columns for any dataset. How would I adapt the following logic to work for all columns/rows in a dataset?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro palindrome (parameter = ?); 

%let string = %sysfunc(reverse(%sysfunc(compress([WHAT TO PUT HERE?],,sp);
%let reverse = %sysfunc(compress([WHAT TO PUT HERE?]);

%if %upcase(&amp;amp;string.) = %upcase(&amp;amp;reverse.)  %then %do;
ods output = "/palindrome"
%end; 

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Mar 2018 14:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444765#M111396</guid>
      <dc:creator>lhsumdalum</dc:creator>
      <dc:date>2018-03-12T14:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Logic to find Palindromes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444772#M111400</link>
      <description>&lt;P&gt;And who told you that you need to use macro?&amp;nbsp; All that does is generate Base SAS which is the programming language and Base SAS has this functionality:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  if strip(reverse(string))=strip(string) then palindrome="Yes";
run; &lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Mar 2018 14:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444772#M111400</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-12T14:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Logic to find Palindromes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444775#M111402</link>
      <description>&lt;P&gt;Thank you for the reply, I plan to use macros because I need to do this for all datasets within a directory. So, instead of the user inputting the string to check if there is a palindrome, I need that to be done dynamically, i.e. identify any palindromes within a dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 14:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444775#M111402</guid>
      <dc:creator>lhsumdalum</dc:creator>
      <dc:date>2018-03-12T14:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Logic to find Palindromes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444778#M111403</link>
      <description>&lt;PRE&gt;data _null_;
  set sashelp.vcolumn (where=(libname="WORK"));
  by memname;
  if first.memname then call execute('data '||strip(memname)||'; set '||strip(memname)||';');
  call execute('if strip(reverse('||strip(name)||'))=strip('||strip(name)||') then '||strip(name)||'_palindrome="Yes";');
  if last.memname then call execute(';run;');
run;
&lt;/PRE&gt;
&lt;P&gt;Will do the palindrome check for every variable in every dataset in the work library. If you just want one dataset, then update the the where clause to be:&lt;/P&gt;
&lt;P&gt;(where=(libname="WORK" and memname="TMP"))&lt;/P&gt;
&lt;P&gt;For example only does TMP in WORK library, upcase is important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 14:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Logic-to-find-Palindromes/m-p/444778#M111403</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-03-12T14:48:26Z</dc:date>
    </item>
  </channel>
</rss>

