<?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 to remove duplicate values in a row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887999#M350835</link>
    <description>&lt;P&gt;I'm using catx to add characters together separated by commas.&amp;nbsp; But some of the columns have duplicated words.&amp;nbsp; And I only need one of those words in the final catx variable.&lt;/P&gt;</description>
    <pubDate>Sat, 05 Aug 2023 02:45:53 GMT</pubDate>
    <dc:creator>arde</dc:creator>
    <dc:date>2023-08-05T02:45:53Z</dc:date>
    <item>
      <title>How to remove duplicate values in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887977#M350824</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to delete duplicates from a row:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 192pt;" border="0" width="256" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;row&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;var1&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;var2&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;var3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;TD&gt;b&lt;/TD&gt;
&lt;TD&gt;b&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD&gt;c&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;TD&gt;c&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;3&lt;/TD&gt;
&lt;TD&gt;a&lt;/TD&gt;
&lt;TD&gt;b&lt;/TD&gt;
&lt;TD&gt;c&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 192pt;" border="0" width="256px" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.7344px" height="20" style="height: 15.0pt; width: 48pt;"&gt;row&lt;/TD&gt;
&lt;TD width="63.7344px" style="width: 48pt;"&gt;var1&lt;/TD&gt;
&lt;TD width="63.75px" style="width: 48pt;"&gt;var2&lt;/TD&gt;
&lt;TD width="63.7812px" style="width: 48pt;"&gt;var3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.7344px" height="20" align="right" style="height: 15.0pt;"&gt;1&lt;/TD&gt;
&lt;TD width="63.7344px"&gt;a&lt;/TD&gt;
&lt;TD width="63.75px"&gt;b&lt;/TD&gt;
&lt;TD width="63.7812px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.7344px" height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD width="63.7344px"&gt;c&lt;/TD&gt;
&lt;TD width="63.75px"&gt;a&lt;/TD&gt;
&lt;TD width="63.7812px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.7344px" height="20" align="right" style="height: 15.0pt;"&gt;3&lt;/TD&gt;
&lt;TD width="63.7344px"&gt;a&lt;/TD&gt;
&lt;TD width="63.75px"&gt;b&lt;/TD&gt;
&lt;TD width="63.7812px"&gt;c&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 22:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887977#M350824</guid>
      <dc:creator>arde</dc:creator>
      <dc:date>2023-08-04T22:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887980#M350825</link>
      <description>&lt;P&gt;Does actual order of the values in the variables matter? Meaning could the result for the second row look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 192pt;" border="0" width="256px" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="63.7344px" height="20" align="right" style="height: 15.0pt;"&gt;2&lt;/TD&gt;
&lt;TD width="63.7344px"&gt;a&lt;/TD&gt;
&lt;TD width="63.75px"&gt;c&lt;/TD&gt;
&lt;TD width="63.7812px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And in your real data are the values other than single characters? There are approaches that may work for single characters that wouldn't for multi-word strings. Which raises the question of does letter case make a difference? Is&lt;/P&gt;
&lt;P&gt;'A' a duplicate for 'a'&amp;nbsp; or is "Apple" a duplicate for "apple"?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 22:28:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887980#M350825</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-04T22:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887991#M350828</link>
      <description>&lt;P&gt;The complexity of the program will very depending on how many fields you are comparing, and whether their names really are var1, var2, var3, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the problem as posted, you could use something simple:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   if var3 = var2 or var3 = var1 then var3 = ' ';
   if var2 = var1 then var2 = ' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I suspect that this will not do in real life, and that the actual problem is a bit more complex.&amp;nbsp; So describe more of what you are really facing.&amp;nbsp; How many variables?&amp;nbsp; What are the variable names?&amp;nbsp; Are they all character variables?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 23:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887991#M350828</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-08-04T23:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887998#M350834</link>
      <description>actual order doesn't matter.  real data will be more than a single character.  Case will be the same.&lt;BR /&gt;&lt;BR /&gt;Thank you!</description>
      <pubDate>Sat, 05 Aug 2023 02:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887998#M350834</guid>
      <dc:creator>arde</dc:creator>
      <dc:date>2023-08-05T02:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887999#M350835</link>
      <description>&lt;P&gt;I'm using catx to add characters together separated by commas.&amp;nbsp; But some of the columns have duplicated words.&amp;nbsp; And I only need one of those words in the final catx variable.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 02:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/887999#M350835</guid>
      <dc:creator>arde</dc:creator>
      <dc:date>2023-08-05T02:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/888000#M350836</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50684"&gt;@arde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm using catx to add characters together separated by commas.&amp;nbsp; But some of the columns have duplicated words.&amp;nbsp; And I only need one of those words in the final catx variable.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What if the duplicate is in the middle of the series of variables?&amp;nbsp; I.e, if your values are&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; A&amp;nbsp; A&amp;nbsp; &amp;nbsp;B&lt;/P&gt;
&lt;P&gt;then if you set the duplicate middle var to blank, and subsequently use CATX('!',var1,var2,var3), you will get two consecutive CATX delimiters (two exclamation marks in this example) in the middle.&amp;nbsp; Is that what you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not, then you could use CATX iteratively, concatenating only the non-duplicates (using '!' as the delimiter below):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=i);
  set have;
  array chr {*} a b c ;
  length new_text $60;
  new_text=left(chr{1});
  do i=2 to dim(chr);
    if findw(trim(new_text),trim(chr{i}),'!')=0 then new_text=catx('!',new_text,chr{i});
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2023 03:13:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/888000#M350836</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-08-05T03:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/888001#M350837</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/50684"&gt;@arde&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm using catx to add characters together separated by commas.&amp;nbsp; But some of the columns have duplicated words.&amp;nbsp; And I only need one of those words in the final catx variable.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In that case there is no need to remove the duplicates.&amp;nbsp; Just don't add them to the list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  length string $200;
  array x var1-var4 ;
  do index=1 to dim(x);
    if not indexw(string,x[index],'|') then 
      string=catx('|',string,x[index])
    ;
  end;
  drop index;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Aug 2023 03:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/888001#M350837</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-05T03:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicate values in a row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/888003#M350839</link>
      <description>thank you!</description>
      <pubDate>Sat, 05 Aug 2023 03:53:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-duplicate-values-in-a-row/m-p/888003#M350839</guid>
      <dc:creator>arde</dc:creator>
      <dc:date>2023-08-05T03:53:35Z</dc:date>
    </item>
  </channel>
</rss>

