<?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: Critical joining in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859177#M339477</link>
    <description>&lt;P&gt;Well, here's&lt;/P&gt;
&lt;PRE&gt;Data T1;
Input ItemNo $10. ItemC1 $8. ItemC2 $8.;
Datalines;
A10  MRF Ceat 
A100 MRF Ceat
B01  IRP  .
B011 IRP CRO 
;
Run;
Data T2;
Input ItemNo $10. ItemC1 - ItemC10 $8.;
Datalines;
A101  MRF . . Ceat . . .
A100 MRF . Ceat 
B01  IRP  . . . CRO
B0101 IRP CRO 
;
Run;

Output: The output table simply have to have the records of (Condition1 T1.ItemNo = T2.ItemNo )) AND  ( Condition2  T1.ItemC1 = T2. (ItemC1 - ItemC10) ) AND ( Condition3 T1.ItemC2 = T2. (ItemC1 - ItemC10) ) ;. The output table should meet these conditions. 
Here Condition1 &amp;amp; 2 means Any value of ItemC1, ItemC2 of Table T1 matches with Any value of ItemC1 to ItemC10 of Table T2 then output the columns from Table T2 for those matched records. 


I hope I made this clear and if you still have doubts please let me know. Thankyou!.
&lt;/PRE&gt;
&lt;P&gt;an example.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2023 12:53:56 GMT</pubDate>
    <dc:creator>Pandu2</dc:creator>
    <dc:date>2023-02-16T12:53:56Z</dc:date>
    <item>
      <title>Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859149#M339468</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I believe you guys are doing fine!. I require some assistance from you as I got stuck while doing joining.&lt;/P&gt;
&lt;P&gt;Here's the explanation :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've two tables T1, T2 and for T1 I've 3 columns named ItemNo, ItemC1, ItemC2 and for table T2 I've ItemNo, ItemC1 to ItemC10. Here, I want to find records where T1.ItemNo= T2.ItemNo and any ItemCode in T1 present in any ItemCode in T2. The final output should have the records of above met condition and the columns should be from table T2 only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much appreciated if anyone could help me on this.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 12:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859149#M339468</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-16T12:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859158#M339469</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405593"&gt;@Pandu2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you only need items from T2 filtered for presence in T1 then rather than using a join you might want to consider a nested SQL query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See a simple example below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HarrySnart_0-1676545252719.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80465iCD311BC516A9A928/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HarrySnart_0-1676545252719.png" alt="HarrySnart_0-1676545252719.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 11:01:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859158#M339469</guid>
      <dc:creator>HarrySnart</dc:creator>
      <dc:date>2023-02-16T11:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859161#M339471</link>
      <description>&lt;P&gt;I appreciate your help Harry but I've mentioned two conditions if you closely observe it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 11:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859161#M339471</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-16T11:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859174#M339476</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405593"&gt;@Pandu2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your question is not very clear. It would help if you put an example of what you have and what you want the output to look like with some dummy records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Re-reading your question, this should still be achievable with nested SQL - you just use the output of the inner join on model as the filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This could be done as a single SQL statement but it would look messier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HarrySnart_0-1676550215021.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80466i3CB85A7CE8DD7264/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HarrySnart_0-1676550215021.png" alt="HarrySnart_0-1676550215021.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 12:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859174#M339476</guid>
      <dc:creator>HarrySnart</dc:creator>
      <dc:date>2023-02-16T12:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859177#M339477</link>
      <description>&lt;P&gt;Well, here's&lt;/P&gt;
&lt;PRE&gt;Data T1;
Input ItemNo $10. ItemC1 $8. ItemC2 $8.;
Datalines;
A10  MRF Ceat 
A100 MRF Ceat
B01  IRP  .
B011 IRP CRO 
;
Run;
Data T2;
Input ItemNo $10. ItemC1 - ItemC10 $8.;
Datalines;
A101  MRF . . Ceat . . .
A100 MRF . Ceat 
B01  IRP  . . . CRO
B0101 IRP CRO 
;
Run;

Output: The output table simply have to have the records of (Condition1 T1.ItemNo = T2.ItemNo )) AND  ( Condition2  T1.ItemC1 = T2. (ItemC1 - ItemC10) ) AND ( Condition3 T1.ItemC2 = T2. (ItemC1 - ItemC10) ) ;. The output table should meet these conditions. 
Here Condition1 &amp;amp; 2 means Any value of ItemC1, ItemC2 of Table T1 matches with Any value of ItemC1 to ItemC10 of Table T2 then output the columns from Table T2 for those matched records. 


I hope I made this clear and if you still have doubts please let me know. Thankyou!.
&lt;/PRE&gt;
&lt;P&gt;an example.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 12:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859177#M339477</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-16T12:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859181#M339479</link>
      <description>&lt;P&gt;To put that output in a better way A100 for ItemNo of T1 matches with A100 for ItemNo of T2 AND MRF for ItemC1 of T1 matches with MRF for ItemC1 of T2 AND Ceat for ItemC2 of T1 matches with Ceat for ItemC3 of T2. Likewise the conditions should match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here values of ItemC1, C2 of Table T1 may found in any variables of T2 for instance, consider the above explanation Value for ItemC2 of T1 found in ItemC3 of T2. So, if any matches found fetch the values from T2 .&lt;/P&gt;
&lt;PRE&gt;Required Output : 
ItemNo  ItemC1  ItemC2  ItemC3  ItemC4 ItemC5 upto ItemC10 
A100     MRF        .    Ceat     .      .            .                 . 
B01      MRF        .     .       .     Ceat          .&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Feb 2023 13:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859181#M339479</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-16T13:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859196#M339481</link>
      <description>&lt;P&gt;How's this? The issue is that you need to search across ItemC1-ItemC10. In this simple approach I transpose T2 so that you get all ItemC1-C10 per ItemNo in a single column, then use that as a nested query.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* example data */
Data T1;
INFILE DATALINES DSD;
Input ItemNo $ ItemC1 $ ItemC2 $;
Datalines;
"A10" , "MRF" , "Ceat" 
"A100" , "MRF" , "Ceat"
"B01" , "IRP" , ""
"B011" , "IRP" , "CRO" 
;

Data T2;
INFILE DATALINES DSD;
Input ItemNo $ (ItemC1 - ItemC10) ($);
Datalines;
"A101", "MRF", "", "", "Ceat", "", "", "", "", "", ""
"A100", "MRF", "", "Ceat" , "" , "" , "", "", "", "",""
"B01",  "IRP" , "" ,"", "", "CRO","","","","",""
"B0101", "IRP", "CRO" ,"","","","","","","",""
;

/* Transpose columns in T2 */
proc sort data=WORK.T2 out=WORK.SORTTempTableSorted;
	by ItemNo;
run;

proc transpose data=WORK.SORTTempTableSorted out=work.Transpose prefix=Column;
	var ItemC1 ItemC2 ItemC3 ItemC4 ItemC5 ItemC6 ItemC7 ItemC8 ItemC9 ItemC10;
	by ItemNo;
run;

proc sql; select * from transpose where column1 ne '';quit;

/* filter condition on list and itemno */
proc sql; select t2.* from t1,t2 
where 
t1.itemno = t2.itemno and 
t1.itemc1 in (select column1 from transpose where itemno = t1.itemno);quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 14:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859196#M339481</guid>
      <dc:creator>HarrySnart</dc:creator>
      <dc:date>2023-02-16T14:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859225#M339487</link>
      <description>&lt;P&gt;You are using some sort of of short hand to describe a condition that needs serious expansion.&lt;/P&gt;
&lt;PRE&gt;T1.ItemC1 = T2. (ItemC1 - ItemC10)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you aware of the IN operator? It will return true if a value is found in a list, so I think you may be looking for:&lt;/P&gt;
&lt;P&gt;t1.itemc1 IN (t2.itemc1 t2.itemc2 t2.itemc3 .... t2.itemc10)&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;t1.itemc2 IN (t2.itemc1 t2.itemc2 t2.itemc3 .... t2.itemc10)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to select records&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 16:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859225#M339487</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-16T16:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859233#M339490</link>
      <description>&lt;P&gt;Yes, I am but does that actually work?.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 16:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859233#M339490</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-16T16:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859237#M339491</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405593"&gt;@Pandu2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes, I am but does that actually work?.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Have you tried it?&lt;/P&gt;
&lt;P&gt;Join ON conditions just need to resolve to true or false.&lt;/P&gt;
&lt;P&gt;Don't like the verbosity needed for SQL so am not going to write out all the variable names.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 16:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859237#M339491</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-16T16:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859308#M339519</link>
      <description>&lt;P&gt;I've tried it but didn't work out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's my code and please suggest me if I made any logical error here.&lt;/P&gt;
&lt;PRE&gt;Proc SQL;
Create table xyz as 
Select * from T2 
Inner join T1 
On T1.ItemNo = T2.ItemNo 
And 
T1. ItemC1 IN ( Select T2.ItemC1 T2.ItemC2  T2.ItemC3 T2.ItemC4 T2.ItemC5 T2.ItemC6 T2.ItemC7 T2.ItemC8 T2.ItemC9 T2.ItemC10 from T2)
OR 
T1. ItemC2 IN ( Select T2.ItemC1 T2.ItemC2  T2.ItemC3 T2.ItemC4 T2.ItemC5 T2.ItemC6 T2.ItemC7 T2.ItemC8 T2.ItemC9 T2.ItemC10 from T2);
Quit;

This code is causing me errors bcuz can we select more than one column in a nested SQL Query?. Please help me on this. Thankyou!.
&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Feb 2023 04:17:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859308#M339519</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-17T04:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859756#M339649</link>
      <description>&lt;P&gt;So this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;T1. ItemC1 IN 
( Select T2.ItemC1 T2.ItemC2  T2.ItemC3 T2.ItemC4 T2.ItemC5 T2.ItemC6 T2.ItemC7 T2.ItemC8 T2.ItemC9 T2.ItemC10 from T2)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is just not valid SQL in so many ways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IN operator in SAS want VALUES in the list, not references to VARIABLES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the WHICHN() or WHICHC() operators can use variables in the list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In normal SAS code you could use variable list (once you have given them all unique names):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;whichc(T1_ItemC1, of  t2_itemc1-t2_itemc10)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But in SQL code you have to actually type out all of the variables (and also the commas that SQL insists on using all over the place).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;whichc(T1.ItemC1 ,t2.itemc1 ,t2.itemc2 ,t2.itemc3 ,t2.itemc4 ,t2.itemc5
 ,t2.itemc6 ,t2.itemc7 ,t2.itemc8 ,t2.itemc9 ,t2.itemc10)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to do what you attempted in SQL you would need a lot of UNIONs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;T1. ItemC1 IN 
( select ItemC1 from T2
union select ItemC2 from T2
union select ItemC3 from T2
union select ItemC4 from T2
union select ItemC5 from T2
union select ItemC6 from T2
union select ItemC7 from T2
union select ItemC8 from T2
union select ItemC9 from T2
union select ItemC10 from T2
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 18:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859756#M339649</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-20T18:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859793#M339667</link>
      <description>&lt;P&gt;Maybe a DATA step approach is better. It does require sorting of the two input tables though. Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data T1;
INFILE DATALINES DSD;
Input ItemNo $ ItemC1 $ ItemC2 $;
Datalines;
"A10" , "MRF" , "Ceat" 
"A100" , "MRF" , "Ceat"
"B01" , "IRP" , ""
"B011" , "IRP" , "CRO" 
;

Data T2;
INFILE DATALINES DSD;
Input ItemNo $ (ItemC1 - ItemC10) ($);
Datalines;
"A101", "MRF", "", "", "Ceat", "", "", "", "", "", ""
"A100", "MRF", "", "Ceat" , "" , "" , "", "", "", "",""
"B01",  "IRP" , "" ,"", "", "CRO","","","","",""
"B0101", "IRP", "CRO" ,"","","","","","","",""
;

proc sort data = T1;
  by ItemNo;
run;

proc sort data = T2;
  by ItemNo;
run;

data Want;
  keep ItemNo T1ItemC1 T1ItemC2 ItemC1 - ItemC10;
  retain T1ItemC1 T1ItemC2;
  set T1 T2;
  by ItemNo;
  array T2 (*) $ ItemC1 - ItemC10;
  if not (first.ItemNo and last.ItemNo) then do;
    if first.ItemNo then do;
	  T1ItemC1 = ItemC1; T1ItemC2 = ItemC2;
	end;
    else do i = 1 to dim(T2);
	  if T1ItemC1 = T2(i) then ItemC1_Match = 'Y';
      if T1ItemC2 = T2(i) then ItemC2_Match = 'Y';
	end;
	if ItemC1_Match = 'Y' and ItemC2_Match = 'Y' then output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Feb 2023 22:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859793#M339667</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-02-20T22:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859843#M339681</link>
      <description>&lt;P&gt;Thanks for your help. However, your code didn't provide me right results.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 06:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859843#M339681</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-21T06:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859930#M339718</link>
      <description>&lt;P&gt;B01 does not have the value MRF anywhere; I guess this is a typo. You should also learn basic DATA step coding and how to test and debug simple steps.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data T1;
Input ItemNo :$10. ItemC1 :$8. ItemC2 :$8.;
Datalines;
A10  MRF Ceat 
A100 MRF Ceat
B01  IRP  .
B011 IRP CRO 
;

Data T2;
infile datalines truncover;
Input ItemNo :$10. (ItemC1 - ItemC10) (:$8.);
Datalines;
A101  MRF . . Ceat . . .
A100 MRF . Ceat 
B01  IRP  . . . CRO
B0101 IRP CRO 
;

proc sort data=t1;
by itemno;
run;

proc sort data=t2;
by itemno;
run;

data want;
merge
  t1 (in=t1)
  t2 (in=t2 rename=(itemc1=_itemc1 itemc2 = _itemc2))
;
by itemno;
if t1 and t2;
array t2c {*} _itemc1 _itemc2 itemc3-itemc10;
do i = 1 to dim(t2c);
  if itemc1 = t2c{i} then f1 = 1;
  if itemc2 = t2c{i} then f2 = 1;
end;
if (f1 or itemc = "") and (f2 or itemc2 = "") then output;
drop _itemc1 _itemc2 i f1 f2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2023 15:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859930#M339718</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-21T15:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859937#M339721</link>
      <description>&lt;P&gt;You data steps aren't going to work as written. So first let's clean that up.&amp;nbsp; We don't need 10 variables to demonstrate the problem so let's cut that down to just 5.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T1;
  input ItemNo :$10. (ItemC1 ItemC2) (:$8.);
datalines;
A10  MRF Ceat 
A100 MRF Ceat
B01  IRP .
B011 IRP CRO 
;
data T2;
  input ItemNo :$10. (ItemC1 - ItemC5) (:$8.);
datalines;
A101  MRF . . Ceat .
A100  MRF . Ceat . . 
B01   IRP . . . CRO
B0101 IRP CRO . . .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It looks like you just want to find the observations in T1 that match so let's do an INNER JOIN.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select a.*
  from t1 a 
  inner join t2 b
  on a.itemno=b.itemno
  and (whichc(a.itemc1,b.itemc1,b.itemc2,b.itemc3,b.itemc4,b.itemc5)
    or whichc(a.itemc2,b.itemc1,b.itemc2,b.itemc3,b.itemc4,b.itemc5)
      )
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;       Item    Item    Item
Obs     No      C1      C2

 1     A100    MRF     Ceat
 2     B01     IRP

&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2023 15:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859937#M339721</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-21T15:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859939#M339722</link>
      <description>&lt;P&gt;I really appreciate your help. However, your code is just only matching the T1 ItemNo with T2 ItemNo and providing the values of ItemC1 - ItemC10 of Table T2 and not looking for the match of T1 ItemC1, ItemC2 across ItemC1 - ItemC10 of Table T2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Besides match of T1 ItemNo with T2 ItemNo, it should also have a match of T1 ItemC1, ItemC2 in any of the columns of Table T2 (i.e T2 (ItemC1 - ItemC10 )). Once both the Conditions have a match then it should output the values of Table T2 for those matches. I hope I'm clear with this. Thanks!.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 16:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859939#M339722</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-21T16:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859943#M339723</link>
      <description>&lt;P&gt;I'm very much thankful for responding. However, the output table what should look like is :&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs ItemNo  ItemC1 ItemC2 ItemC3 ItemC4 ItemC5 
1    A100    MRF      .    CEAT 
2    B01     IRP      .     .      .      .


This is how my output should look like, if the value of ItemC1, ItemC2 of T1 matches with any column of T2 then, it should output those matched values in whatever place they exist in T2. &lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Feb 2023 03:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859943#M339723</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2023-02-22T03:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859944#M339724</link>
      <description>&lt;P&gt;So you want the records from T2 instead of the records from T1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That should be TRIVIAL to fix.&lt;/P&gt;
&lt;P&gt;Did you try to fix it?&lt;BR /&gt;What happened.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 16:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859944#M339724</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-21T16:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Critical joining</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859946#M339725</link>
      <description>&lt;P&gt;My code creates the exact output dataset from your own posting, with the exception of the value for B01 as mentioned.&lt;/P&gt;
&lt;P&gt;If you need something different, you&amp;nbsp;will&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;post example data in &amp;nbsp;WORKING data steps&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;include enough cases for all possibilities&lt;/LI&gt;
&lt;LI&gt;post the exact expected result form this&lt;/LI&gt;
&lt;LI&gt;clearly define the rules&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Expect no further answer from me if these four points have not been met.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 16:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Critical-joining/m-p/859946#M339725</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-21T16:20:55Z</dc:date>
    </item>
  </channel>
</rss>

