<?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 how to remove duplicate values by using arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721849#M223778</link>
    <description>&lt;P&gt;data a1 ;&lt;BR /&gt;var1='abc' ;&lt;BR /&gt;var2='def' ;&lt;BR /&gt;var3='ghi' ;&lt;BR /&gt;var4='abc' ;&lt;BR /&gt;var5='xyz' ;&lt;BR /&gt;var6='def' ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;I have above dataset. how to remove duplicate values column wise in arrays.&lt;/P&gt;
&lt;P&gt;output come should come like see below example&lt;/P&gt;
&lt;P&gt;var1=abc&amp;nbsp; var2='def'&amp;nbsp; &amp;nbsp;var3='ghi'&amp;nbsp; var4=' '&amp;nbsp; &amp;nbsp;var5='xyz'&amp;nbsp; var6=' '&lt;/P&gt;
&lt;P&gt;var4 and var6 we have to assign missing values because there values already in var1 and var2.&lt;/P&gt;
&lt;P&gt;I have tried below code. Kindly help me out.&lt;/P&gt;
&lt;P&gt;code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a1 ;&lt;BR /&gt;var1='abc' ;&lt;BR /&gt;var2='def' ;&lt;BR /&gt;var3='ghi' ;&lt;BR /&gt;var4='abc' ;&lt;BR /&gt;var5='xyz' ;&lt;BR /&gt;var6='def' ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data a2 ;&lt;BR /&gt;set a1 ;&lt;BR /&gt;array apple(6) $ var1-var6 ;&lt;BR /&gt;do i=1 to 5;&lt;BR /&gt;do j=2 to 6 ;&lt;BR /&gt;if apple(i) ne ' ' and apple(j) ne ' ' then do ;&lt;BR /&gt;if (apple(i) ne ' ' and apple(j) ne ' ') and apple(i)=apple(j) then apple(i)=' ' ;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Feb 2021 13:20:52 GMT</pubDate>
    <dc:creator>thanikondharish</dc:creator>
    <dc:date>2021-02-25T13:20:52Z</dc:date>
    <item>
      <title>how to remove duplicate values by using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721849#M223778</link>
      <description>&lt;P&gt;data a1 ;&lt;BR /&gt;var1='abc' ;&lt;BR /&gt;var2='def' ;&lt;BR /&gt;var3='ghi' ;&lt;BR /&gt;var4='abc' ;&lt;BR /&gt;var5='xyz' ;&lt;BR /&gt;var6='def' ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;I have above dataset. how to remove duplicate values column wise in arrays.&lt;/P&gt;
&lt;P&gt;output come should come like see below example&lt;/P&gt;
&lt;P&gt;var1=abc&amp;nbsp; var2='def'&amp;nbsp; &amp;nbsp;var3='ghi'&amp;nbsp; var4=' '&amp;nbsp; &amp;nbsp;var5='xyz'&amp;nbsp; var6=' '&lt;/P&gt;
&lt;P&gt;var4 and var6 we have to assign missing values because there values already in var1 and var2.&lt;/P&gt;
&lt;P&gt;I have tried below code. Kindly help me out.&lt;/P&gt;
&lt;P&gt;code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data a1 ;&lt;BR /&gt;var1='abc' ;&lt;BR /&gt;var2='def' ;&lt;BR /&gt;var3='ghi' ;&lt;BR /&gt;var4='abc' ;&lt;BR /&gt;var5='xyz' ;&lt;BR /&gt;var6='def' ;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data a2 ;&lt;BR /&gt;set a1 ;&lt;BR /&gt;array apple(6) $ var1-var6 ;&lt;BR /&gt;do i=1 to 5;&lt;BR /&gt;do j=2 to 6 ;&lt;BR /&gt;if apple(i) ne ' ' and apple(j) ne ' ' then do ;&lt;BR /&gt;if (apple(i) ne ' ' and apple(j) ne ' ') and apple(i)=apple(j) then apple(i)=' ' ;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 13:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721849#M223778</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2021-02-25T13:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove duplicate values by using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721852#M223780</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a2 ;
    set a1 ;
    array apple(6) $ var1-var6 ;
    do i=1 to 5;
        do j=i+1 to 6 ;
            if apple(i) ne ' ' and apple(j) ne ' ' then do ;
                if apple(i)=apple(j) then apple(i)=' ' ;
            end;
        end;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please, from now on, post your code in a code box, as I have done, by clicking on the "running man" icon and then pasting your code into the box.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, do yourself a favor and indent your code as shown above.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 13:41:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721852#M223780</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-25T13:41:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove duplicate values by using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721887#M223793</link>
      <description>&lt;P&gt;Depending on the number of observation i would tend to transpose the data and use proc sort to remove the duplicates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=a1 out=transposed;
   var var:;
run;

proc sort data=transposed out=nodups nodupkey;
   by col1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721887#M223793</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-25T14:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove duplicate values by using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721888#M223794</link>
      <description>Sorry , We have to do in arrays only&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721888#M223794</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2021-02-25T14:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove duplicate values by using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721890#M223796</link>
      <description>&lt;P&gt;For anyone who doesn't have the restriction of doing it in arrays (which I think would be almost everyone), I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;has the correct (and easiest) answer.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:53:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721890#M223796</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-25T14:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove duplicate values by using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721891#M223797</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry , We have to do in arrays only&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 14:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/721891#M223797</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-25T14:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to remove duplicate values by using arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/722141#M223881</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a1 ;
var1='abc' ;
var2='def' ;
var3='ghi' ;
var4='abc' ;
var5='xyz' ;
var6='def' ;
run;

data a2 ;
set a1 ;
array apple(6) $ var1-var6 ;
array temp(6) $ temp1-temp6 ;
do i=1 to dim(apple);
  if apple{i} in temp then call missing(apple{i});
   else temp{i}=apple{i};
end;
drop i temp:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Feb 2021 13:55:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-remove-duplicate-values-by-using-arrays/m-p/722141#M223881</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-02-26T13:55:20Z</dc:date>
    </item>
  </channel>
</rss>

