<?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 Concatenation removing duplicates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-removing-duplicates/m-p/775174#M246419</link>
    <description>Good day &lt;BR /&gt;&lt;BR /&gt;Please assist I am trying to concatenate 4 variables but if the values are duplicates I will like to output just a single value.&lt;BR /&gt;&lt;BR /&gt;I have given an example below:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Var1    Var2    Var3   Var4&lt;BR /&gt;IN4       IN4      IN4    IN4&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Concatenate:&lt;BR /&gt;New_Var = var1||"/"||var2||"/"||var3||"/"||var4&lt;BR /&gt;&lt;BR /&gt;The expected value of variable New_Var should be IN4 not IN4/IN4/IN4/IN4&lt;BR /&gt;&lt;BR /&gt;Thank you &lt;BR /&gt;Kind Regards &lt;BR /&gt;Dinkepile</description>
    <pubDate>Tue, 19 Oct 2021 16:58:16 GMT</pubDate>
    <dc:creator>Dinkepile</dc:creator>
    <dc:date>2021-10-19T16:58:16Z</dc:date>
    <item>
      <title>Concatenation removing duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-removing-duplicates/m-p/775174#M246419</link>
      <description>Good day &lt;BR /&gt;&lt;BR /&gt;Please assist I am trying to concatenate 4 variables but if the values are duplicates I will like to output just a single value.&lt;BR /&gt;&lt;BR /&gt;I have given an example below:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Var1    Var2    Var3   Var4&lt;BR /&gt;IN4       IN4      IN4    IN4&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Concatenate:&lt;BR /&gt;New_Var = var1||"/"||var2||"/"||var3||"/"||var4&lt;BR /&gt;&lt;BR /&gt;The expected value of variable New_Var should be IN4 not IN4/IN4/IN4/IN4&lt;BR /&gt;&lt;BR /&gt;Thank you &lt;BR /&gt;Kind Regards &lt;BR /&gt;Dinkepile</description>
      <pubDate>Tue, 19 Oct 2021 16:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-removing-duplicates/m-p/775174#M246419</guid>
      <dc:creator>Dinkepile</dc:creator>
      <dc:date>2021-10-19T16:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenation removing duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-removing-duplicates/m-p/775188#M246420</link>
      <description>&lt;P&gt;No data so untested;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data want;
   set have;
   array values (*) var1-var4;
   length new_var $ 16 ; /* this needs to large enough to accept the longest possible value*/
   do i=1 to dim(values);
      if indexw(new_var,values[i],'/')= 0 then new_var= catx('/',new_var,values[i]);
   end;
   drop i;
run;
&lt;/PRE&gt;
&lt;P&gt;This searches the value of the new_var for each of the variables and if it is not currently present then concatenates.&lt;/P&gt;
&lt;P&gt;If your variables actually have different names then the order they appear on the Array statement is the order they are processed.&lt;/P&gt;
&lt;P&gt;If the values vary by case "In4" "in4" "iN4" all of these would appear. So you may need to clean data first if spelling or case differences may occur.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 17:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-removing-duplicates/m-p/775188#M246420</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-19T17:56:34Z</dc:date>
    </item>
  </channel>
</rss>

