<?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 join two datasets when the joining key has mixed values from two variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765360#M242429</link>
    <description>It's one to one join</description>
    <pubDate>Wed, 01 Sep 2021 14:19:22 GMT</pubDate>
    <dc:creator>Shradha1</dc:creator>
    <dc:date>2021-09-01T14:19:22Z</dc:date>
    <item>
      <title>How to join two datasets when the joining key has mixed values from two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765218#M242370</link>
      <description>&lt;P&gt;I have two datasets A and B. Dataset A has only 1 field named 'Key', the values of which can either be Account number or Card Number. It is not known which value in 'Key' is what.&lt;/P&gt;
&lt;P&gt;Another dataset B has 3 fields: Account_num, Card_Num, and Customer_Num.&lt;/P&gt;
&lt;P&gt;I want to left join these two datasets, on Dataset A, where I want to bring in the Customer Number from B,&amp;nbsp; corresponding to each Key in dataset A.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there any condition or any case-when statement that can be applied for this case, such that first A.KEY will be joined with B.Account_num, and in case there is no match found then,&amp;nbsp;A.KEY will be joined with B.Card_Num to pick the customer number ?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 05:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765218#M242370</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-09-01T05:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two datasets when the joining key has mixed values from two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765225#M242374</link>
      <description>&lt;P&gt;For example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table c as 
    select a.*, b.* 
        from a left outer join b on (a.key=b.account_num and b.account_num ne .) or 
                                    (a.key=b.card_num and b.card_num ne .) 
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Sep 2021 06:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765225#M242374</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-09-01T06:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two datasets when the joining key has mixed values from two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765280#M242387</link>
      <description>&lt;P&gt;if it's one-to-many, maybe MERGE could help:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
input key;
cards;
1
2
3
4
5
10
20
30
40
50
;
run;

data b(index=(account_num card_num));
input account_num card_num name $;
cards;
1 10 A
2 .  B
. 30 C
6 60 D
;
run;

data want;
  merge A(in=inA) B(rename=(account_num=key)) B(rename=(card_num=key));
  by key;
  if inA;
run;
proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 01 Sep 2021 09:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765280#M242387</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-09-01T09:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two datasets when the joining key has mixed values from two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765359#M242428</link>
      <description>This worked. Thanks a lot!&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Sep 2021 14:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765359#M242428</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-09-01T14:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two datasets when the joining key has mixed values from two variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765360#M242429</link>
      <description>It's one to one join</description>
      <pubDate>Wed, 01 Sep 2021 14:19:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-join-two-datasets-when-the-joining-key-has-mixed-values/m-p/765360#M242429</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-09-01T14:19:22Z</dc:date>
    </item>
  </channel>
</rss>

