<?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 common values in 2 ional in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/682212#M206494</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;A class="trigger-hovercard" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461" target="_blank" rel="noopener"&gt;mkeintz,&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Just an additional help is needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just want to compare all the Depo_IDs for one group to Shop_IDs, if all the IDs matched then Comments should print "Matched" or else "Not Matched".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="1154px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="102px" height="29px"&gt;Pet_Names&lt;/TD&gt;
&lt;TD width="100.667px" height="29px"&gt;Depo_Count&lt;/TD&gt;
&lt;TD width="206.667px" height="29px"&gt;Depo_IDs&lt;/TD&gt;
&lt;TD width="100px" height="29px"&gt;Shop_Count&lt;/TD&gt;
&lt;TD width="208.667px" height="29px"&gt;Shop_IDs&lt;/TD&gt;
&lt;TD width="88.6667px" height="29px"&gt;Comments&lt;/TD&gt;
&lt;TD width="174px" height="29px"&gt;Depo_Id_Not_In_Shop&lt;/TD&gt;
&lt;TD width="172.667px" height="29px"&gt;Shop_Id_Not_in_Depo&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="29px"&gt;Dog&lt;/TD&gt;
&lt;TD width="100.667px" height="29px"&gt;2&lt;/TD&gt;
&lt;TD width="206.667px" height="29px"&gt;6346560,6354972&lt;/TD&gt;
&lt;TD width="100px" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="208.667px" height="29px"&gt;6354972&lt;/TD&gt;
&lt;TD width="88.6667px" height="29px"&gt;Matched&lt;/TD&gt;
&lt;TD width="174px" height="29px"&gt;6346560&lt;/TD&gt;
&lt;TD width="172.667px" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="29px"&gt;Dog&lt;/TD&gt;
&lt;TD width="100.667px" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="206.667px" height="29px"&gt;6360302&lt;/TD&gt;
&lt;TD width="100px" height="29px"&gt;2&lt;/TD&gt;
&lt;TD width="208.667px" height="29px"&gt;6346560,6360302&lt;/TD&gt;
&lt;TD width="88.6667px" height="29px"&gt;Matched&lt;/TD&gt;
&lt;TD width="174px" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="172.667px" height="29px"&gt;6346560&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="56px"&gt;Cat&lt;/TD&gt;
&lt;TD width="100.667px" height="56px"&gt;1&lt;/TD&gt;
&lt;TD width="206.667px" height="56px"&gt;6320478,6296089&lt;/TD&gt;
&lt;TD width="100px" height="56px"&gt;1&lt;/TD&gt;
&lt;TD width="208.667px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;TD width="88.6667px" height="56px"&gt;Not Matched&lt;/TD&gt;
&lt;TD width="174px" height="56px"&gt;6320478,6296089&lt;/TD&gt;
&lt;TD width="172.667px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="56px"&gt;Cat&lt;/TD&gt;
&lt;TD width="100.667px" height="56px"&gt;3&lt;/TD&gt;
&lt;TD width="206.667px" height="56px"&gt;6296088,6327084,6354370&lt;/TD&gt;
&lt;TD width="100px" height="56px"&gt;3&lt;/TD&gt;
&lt;TD width="208.667px" height="56px"&gt;6320478,6327084,6354370&lt;/TD&gt;
&lt;TD width="88.6667px" height="56px"&gt;Not Matched&lt;/TD&gt;
&lt;TD width="174px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;TD width="172.667px" height="56px"&gt;6320478&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="56px"&gt;Pigeon&lt;/TD&gt;
&lt;TD width="100.667px" height="56px"&gt;1&lt;/TD&gt;
&lt;TD width="206.667px" height="56px"&gt;6320478,6296089&lt;/TD&gt;
&lt;TD width="100px" height="56px"&gt;0&lt;/TD&gt;
&lt;TD width="208.667px" height="56px"&gt;.&lt;/TD&gt;
&lt;TD width="88.6667px" height="56px"&gt;Not Matched&lt;/TD&gt;
&lt;TD width="174px" height="56px"&gt;6320478,6296089&lt;/TD&gt;
&lt;TD width="172.667px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="56px"&gt;Pigeon&lt;/TD&gt;
&lt;TD width="100.667px" height="56px"&gt;3&lt;/TD&gt;
&lt;TD width="206.667px" height="56px"&gt;6296088,6327084,6354370&lt;/TD&gt;
&lt;TD width="100px" height="56px"&gt;3&lt;/TD&gt;
&lt;TD width="208.667px" height="56px"&gt;6320478,6327084,6354370&lt;/TD&gt;
&lt;TD width="88.6667px" height="56px"&gt;Not Matched&lt;/TD&gt;
&lt;TD width="174px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;TD width="172.667px" height="56px"&gt;6320478&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Parrot&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;6327084&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;6327084&lt;/TD&gt;
&lt;TD&gt;Matched&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&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;The above is the expected output.&lt;/P&gt;
&lt;P&gt;Like, From Dog Category total 3 Depo_Ids are there and that has to get compared with 3 Shop_Ids from Dog Category. You can see if 3 vs 3 will be compared, token by token then it will be matched and Comments Column should go as "Matched".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same like for Cat: 4 vs 4 will be compared&lt;/P&gt;
&lt;P&gt;Pigeon: 4 vs 3 will be compared and so on.&lt;/P&gt;
&lt;P&gt;In simple words, all the Depo_ids from one Pet_names group will be compared to Shop_ids from the same group, if matched then Comments=Matched else Not matched.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have already done the same with almost 5 steps.&lt;/P&gt;
&lt;P&gt;The below is my code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME REFFILE 'C:\Pet_Depo.xlsx';
PROC IMPORT DATAFILE=REFFILE replace
	DBMS=XLSX
	OUT=WORK.Pet_Depo;
	GETNAMES=YES;
RUN;

proc sort data=Pet_Depo;
by Pet_Names;
run;

data grp_id_plt(drop=Comments);
set Pet_Depo ;
length Depo_Id_concat Shop_Id_concat $400;
by Pet_Names ;
retain Depo_Id_concat Shop_Id_concat ;
if first.Pet_Names then do ;
group_id =1;
Depo_Id_concat ='';
Shop_Id_concat ='';
end;
 do i=1 to countw(Depo_IDs);
    Depo_Id_concat=catx(';',strip(Depo_Id_concat),scan(Depo_IDs,i,','));
end;
do i=1 to countw(Shop_IDs);
	Shop_Id_concat =catx(";",strip(Shop_Id_concat),scan(Shop_IDs,i,','));
end;
group_id+1;
if last.Pet_Names then output;
run;

data Comments_holder;
length Comments $20;
set grp_id_plt;
set_con_shop = 'Matched';
do i=1 to countw(Shop_Id_concat,';');
if set_con_shop = 'Matched' then do;
con_shop = findw(Depo_Id_concat,strip(scan(Shop_Id_concat,i))) ;
if con_shop = 0 then set_con_shop = 'Not Matched';
end;
end;
set_con_depo = 'Matched';
do i=1 to countw(Depo_Id_concat,';');
if set_con_depo = 'Matched' then do;
con_depo = findw(Shop_Id_concat ,strip(scan(Depo_Id_concat,i))) ;
if con_depo = 0 then set_con_depo = 'Not Matched';
end;
end;
if set_con_shop = 'Matched' and set_con_depo ='Matched' then Comments = 'Matched';
else Comments = 'Not Matched';
drop set_con_shop set_con_depo con_shop con_depo i ;
run;

PROC SQL;
   CREATE TABLE WORK.Final AS 
   SELECT DISTINCT t1.Pet_Names, 
          
          t1.Depo_Count, 
          t1.Depo_IDs, 
          t1.Shop_Count, 
          t1.Shop_IDs, 
          t1.Depo_Id_Not_In_Shop, 
          t1.Shop_Id_Not_in_Depo, 
          t2.Comments
      FROM WORK.Pet_Depo t1
           LEFT JOIN WORK.Comments_HOLDER t2 ON (t1.Pet_Names = t2.Pet_Names);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please suggest if any alternate way can I do the same or in lesser steps if it's possible suppose.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 08 Sep 2020 11:49:40 GMT</pubDate>
    <dc:creator>rajdeep</dc:creator>
    <dc:date>2020-09-08T11:49:40Z</dc:date>
    <item>
      <title>How to remove common values in 2 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/597002#M171992</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two columns. I want to remove the common values and replace it with a space and want to store the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Emp_Accounts&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sales_Accounts&lt;BR /&gt;239676,239690,240754&amp;nbsp; &amp;nbsp;239676,240754&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result I need is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Emp_Accounts&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sales_Accounts&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Emp_Acc_Not_in_Sales&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sales_Acc_Not_in_Emp&lt;BR /&gt;239676,239690,240754&amp;nbsp; &amp;nbsp;239676,240754,234563&amp;nbsp; &amp;nbsp; &amp;nbsp; 239690&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 234563&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried the below code, but I think I am missing something.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3(drop=i EMp_Count Sales_Count);
set test;

length want $100;
     length Emp_Acc_Not_in_Sales $40;
 length sales_Acc_Not_in_Emp $40;
Emp_Count=countw(Emp_Count);
Sales_Count=countw(Sales_Count);
if Emp_Count&amp;gt; Sales_Count then do;
retain Emp_Acc_Not_in_Sales sales_Acc_Not_in_Emp ;
do i=1 to countw(Emp_Accounts);
      string=strip(scan(Emp_Accounts, i, ','));
      if find(Emp_Accounts, string, 'it') &amp;gt; 0 then Emp_Acc_Not_in_Sales = tranwrd(Emp_Accounts, strip(string), ' ');
if find(Sales_Accounts, string, 'it') &amp;gt; 0 then sales_Acc_Not_in_Emp =tranwrd(Sales_Accounts, strip(string), ' ');
     end;
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;The above code is not holding the value in&amp;nbsp;&lt;CODE class=" language-sas"&gt;Emp_Acc_Not_in_Sales &amp;amp;&amp;nbsp;sales_Acc_Not_in_Emp in the next iteration.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Please help me if possible.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;Thanks in advance.&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 17:51:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/597002#M171992</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2019-10-16T17:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove common values in 2 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/597017#M171995</link>
      <description>&lt;P&gt;Instead of the FIND function, use the FINDW (find word) function.&amp;nbsp; It will simplify your treatment of word delimiters.&amp;nbsp; In fact, it assume the delimiters include comma's and blanks, which is what you need here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Emp_Accounts :$20.      Sales_Accounts :$20. ;
  put (_all_) (=);
datalines;
239676,239690,240754   239676,240754
run;

data want (drop=i);
  set have;
  length not_in_sales_accounts not_in_emp_accounts $20;
  do i=1 to countw(emp_accounts);
    if findw(sales_accounts,scan(emp_accounts,i,',')) = 0 then 
    not_in_sales_accounts=catx(',',not_in_sales_accounts,scan(emp_accounts,i,','));
  end;
  do i=1 to countw(sales_accounts);
    if findw(emp_accounts,scan(sales_accounts,i,',')) = 0 then 
    not_in_emp_accounts=catx(',',not_in_emp_accounts,scan(sales_accounts,i,','));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 18:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/597017#M171995</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-16T18:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove common values in 2 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/597151#M172031</link>
      <description>&lt;P&gt;The output does not match your description. You are not removing values, you add values.&lt;BR /&gt;Please state your goal more clearly.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 03:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/597151#M172031</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-10-17T03:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove common values in 2 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/597206#M172067</link>
      <description>&lt;P&gt;Hi Chrisnz,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the sample example in the above clearly showing what should be the expected output. Yeah, the code I had written that's somehow was not doing as expected. I want to check the one column values with another and if match found then I just want to remove the same and keep the remaining.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope that helps for your understanding. Please let me know if still there's any disconnect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your response.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 08:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/597206#M172067</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2019-10-17T08:20:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove common values in 2 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/598993#M172820</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;Just one small ask. Please help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;I am running the below code with the following values, but the output is catching one account extra in&amp;nbsp;&lt;CODE class=" language-sas"&gt;&lt;STRONG&gt;not_in_emp_accounts&lt;/STRONG&gt;.&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Emp_Accounts :$200.      Sales_Accounts :$200. ;
  put (_all_) (=);
datalines;
239684,239789,240173,240262,240760,241149,241175,241240,241249,241691,241750   240740,241149
run;

data want (drop=i);
  set have;
  length not_in_sales_accounts not_in_emp_accounts $200;
  do i=1 to countw(emp_accounts);
    if findw(sales_accounts,scan(emp_accounts,i,',')) = 0 then 
    not_in_sales_accounts=catx(',',not_in_sales_accounts,scan(emp_accounts,i,','));
  end;
  do i=1 to countw(sales_accounts);
    if findw(emp_accounts,scan(sales_accounts,i,',')) = 0 then 
    not_in_emp_accounts=catx(',',not_in_emp_accounts,scan(sales_accounts,i,','));
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output is coming like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;not_in_sales_accounts&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;not_in_emp_accounts&lt;BR /&gt;239684,239789,240173,240262,240760,241175,241240,241249,241691,241750&amp;nbsp; &amp;nbsp; &amp;nbsp;240740,241149&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But you can see that &lt;STRONG&gt;241149&lt;/STRONG&gt; is already present in &lt;STRONG&gt;emp_accounts.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rather the output should come:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;not_in_sales_accounts&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;not_in_emp_accounts&lt;BR /&gt;239684,239789,240173,240262,240760,241175,241240,241249,241691,241750&amp;nbsp; &amp;nbsp; &amp;nbsp;240740&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you got my point. Can you please explain why it's catching the common account which is already present in both especially in this case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help. Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 14:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/598993#M172820</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2019-10-24T14:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove common values in 2 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/599266#M172960</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help me if possible what I am missing in the above code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 09:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/599266#M172960</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2019-10-25T09:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove common values in 2 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/599277#M172965</link>
      <description>&lt;P&gt;All char vars are padded with blanks, so the last value returned by scan will have lots of blanks at its end and findw searches for "241149&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ", which is not in the list. Trimming the result of scan should solve the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if findw(sales_accounts, trim(scan(emp_accounts, i, ','))) = 0 then do;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2019 10:56:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/599277#M172965</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-10-25T10:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove common values in 2 columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/599280#M172967</link>
      <description>&lt;P&gt;Wow....Andreas_lds... It's working now......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;You are great... I am so silly.... Hehe.....&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;Kudos to you.....Have a great day ahead... Thanks a lot.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 11:16:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/599280#M172967</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2019-10-25T11:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove common values in 2 ional</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/682212#M206494</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A class="trigger-hovercard" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461" target="_blank" rel="noopener"&gt;mkeintz,&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Just an additional help is needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just want to compare all the Depo_IDs for one group to Shop_IDs, if all the IDs matched then Comments should print "Matched" or else "Not Matched".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="1154px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="102px" height="29px"&gt;Pet_Names&lt;/TD&gt;
&lt;TD width="100.667px" height="29px"&gt;Depo_Count&lt;/TD&gt;
&lt;TD width="206.667px" height="29px"&gt;Depo_IDs&lt;/TD&gt;
&lt;TD width="100px" height="29px"&gt;Shop_Count&lt;/TD&gt;
&lt;TD width="208.667px" height="29px"&gt;Shop_IDs&lt;/TD&gt;
&lt;TD width="88.6667px" height="29px"&gt;Comments&lt;/TD&gt;
&lt;TD width="174px" height="29px"&gt;Depo_Id_Not_In_Shop&lt;/TD&gt;
&lt;TD width="172.667px" height="29px"&gt;Shop_Id_Not_in_Depo&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="29px"&gt;Dog&lt;/TD&gt;
&lt;TD width="100.667px" height="29px"&gt;2&lt;/TD&gt;
&lt;TD width="206.667px" height="29px"&gt;6346560,6354972&lt;/TD&gt;
&lt;TD width="100px" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="208.667px" height="29px"&gt;6354972&lt;/TD&gt;
&lt;TD width="88.6667px" height="29px"&gt;Matched&lt;/TD&gt;
&lt;TD width="174px" height="29px"&gt;6346560&lt;/TD&gt;
&lt;TD width="172.667px" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="29px"&gt;Dog&lt;/TD&gt;
&lt;TD width="100.667px" height="29px"&gt;1&lt;/TD&gt;
&lt;TD width="206.667px" height="29px"&gt;6360302&lt;/TD&gt;
&lt;TD width="100px" height="29px"&gt;2&lt;/TD&gt;
&lt;TD width="208.667px" height="29px"&gt;6346560,6360302&lt;/TD&gt;
&lt;TD width="88.6667px" height="29px"&gt;Matched&lt;/TD&gt;
&lt;TD width="174px" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="172.667px" height="29px"&gt;6346560&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="56px"&gt;Cat&lt;/TD&gt;
&lt;TD width="100.667px" height="56px"&gt;1&lt;/TD&gt;
&lt;TD width="206.667px" height="56px"&gt;6320478,6296089&lt;/TD&gt;
&lt;TD width="100px" height="56px"&gt;1&lt;/TD&gt;
&lt;TD width="208.667px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;TD width="88.6667px" height="56px"&gt;Not Matched&lt;/TD&gt;
&lt;TD width="174px" height="56px"&gt;6320478,6296089&lt;/TD&gt;
&lt;TD width="172.667px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="56px"&gt;Cat&lt;/TD&gt;
&lt;TD width="100.667px" height="56px"&gt;3&lt;/TD&gt;
&lt;TD width="206.667px" height="56px"&gt;6296088,6327084,6354370&lt;/TD&gt;
&lt;TD width="100px" height="56px"&gt;3&lt;/TD&gt;
&lt;TD width="208.667px" height="56px"&gt;6320478,6327084,6354370&lt;/TD&gt;
&lt;TD width="88.6667px" height="56px"&gt;Not Matched&lt;/TD&gt;
&lt;TD width="174px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;TD width="172.667px" height="56px"&gt;6320478&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="56px"&gt;Pigeon&lt;/TD&gt;
&lt;TD width="100.667px" height="56px"&gt;1&lt;/TD&gt;
&lt;TD width="206.667px" height="56px"&gt;6320478,6296089&lt;/TD&gt;
&lt;TD width="100px" height="56px"&gt;0&lt;/TD&gt;
&lt;TD width="208.667px" height="56px"&gt;.&lt;/TD&gt;
&lt;TD width="88.6667px" height="56px"&gt;Not Matched&lt;/TD&gt;
&lt;TD width="174px" height="56px"&gt;6320478,6296089&lt;/TD&gt;
&lt;TD width="172.667px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="102px" height="56px"&gt;Pigeon&lt;/TD&gt;
&lt;TD width="100.667px" height="56px"&gt;3&lt;/TD&gt;
&lt;TD width="206.667px" height="56px"&gt;6296088,6327084,6354370&lt;/TD&gt;
&lt;TD width="100px" height="56px"&gt;3&lt;/TD&gt;
&lt;TD width="208.667px" height="56px"&gt;6320478,6327084,6354370&lt;/TD&gt;
&lt;TD width="88.6667px" height="56px"&gt;Not Matched&lt;/TD&gt;
&lt;TD width="174px" height="56px"&gt;6296088&lt;/TD&gt;
&lt;TD width="172.667px" height="56px"&gt;6320478&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Parrot&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;6327084&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;6327084&lt;/TD&gt;
&lt;TD&gt;Matched&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&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;The above is the expected output.&lt;/P&gt;
&lt;P&gt;Like, From Dog Category total 3 Depo_Ids are there and that has to get compared with 3 Shop_Ids from Dog Category. You can see if 3 vs 3 will be compared, token by token then it will be matched and Comments Column should go as "Matched".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Same like for Cat: 4 vs 4 will be compared&lt;/P&gt;
&lt;P&gt;Pigeon: 4 vs 3 will be compared and so on.&lt;/P&gt;
&lt;P&gt;In simple words, all the Depo_ids from one Pet_names group will be compared to Shop_ids from the same group, if matched then Comments=Matched else Not matched.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have already done the same with almost 5 steps.&lt;/P&gt;
&lt;P&gt;The below is my code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME REFFILE 'C:\Pet_Depo.xlsx';
PROC IMPORT DATAFILE=REFFILE replace
	DBMS=XLSX
	OUT=WORK.Pet_Depo;
	GETNAMES=YES;
RUN;

proc sort data=Pet_Depo;
by Pet_Names;
run;

data grp_id_plt(drop=Comments);
set Pet_Depo ;
length Depo_Id_concat Shop_Id_concat $400;
by Pet_Names ;
retain Depo_Id_concat Shop_Id_concat ;
if first.Pet_Names then do ;
group_id =1;
Depo_Id_concat ='';
Shop_Id_concat ='';
end;
 do i=1 to countw(Depo_IDs);
    Depo_Id_concat=catx(';',strip(Depo_Id_concat),scan(Depo_IDs,i,','));
end;
do i=1 to countw(Shop_IDs);
	Shop_Id_concat =catx(";",strip(Shop_Id_concat),scan(Shop_IDs,i,','));
end;
group_id+1;
if last.Pet_Names then output;
run;

data Comments_holder;
length Comments $20;
set grp_id_plt;
set_con_shop = 'Matched';
do i=1 to countw(Shop_Id_concat,';');
if set_con_shop = 'Matched' then do;
con_shop = findw(Depo_Id_concat,strip(scan(Shop_Id_concat,i))) ;
if con_shop = 0 then set_con_shop = 'Not Matched';
end;
end;
set_con_depo = 'Matched';
do i=1 to countw(Depo_Id_concat,';');
if set_con_depo = 'Matched' then do;
con_depo = findw(Shop_Id_concat ,strip(scan(Depo_Id_concat,i))) ;
if con_depo = 0 then set_con_depo = 'Not Matched';
end;
end;
if set_con_shop = 'Matched' and set_con_depo ='Matched' then Comments = 'Matched';
else Comments = 'Not Matched';
drop set_con_shop set_con_depo con_shop con_depo i ;
run;

PROC SQL;
   CREATE TABLE WORK.Final AS 
   SELECT DISTINCT t1.Pet_Names, 
          
          t1.Depo_Count, 
          t1.Depo_IDs, 
          t1.Shop_Count, 
          t1.Shop_IDs, 
          t1.Depo_Id_Not_In_Shop, 
          t1.Shop_Id_Not_in_Depo, 
          t2.Comments
      FROM WORK.Pet_Depo t1
           LEFT JOIN WORK.Comments_HOLDER t2 ON (t1.Pet_Names = t2.Pet_Names);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please suggest if any alternate way can I do the same or in lesser steps if it's possible suppose.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 11:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-common-values-in-2-columns/m-p/682212#M206494</guid>
      <dc:creator>rajdeep</dc:creator>
      <dc:date>2020-09-08T11:49:40Z</dc:date>
    </item>
  </channel>
</rss>

