<?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 columns from one table to a different table based matching criteria in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-join-two-columns-from-one-table-to-a-different-table/m-p/637991#M19092</link>
    <description>&lt;P&gt;If you don't insist on having two variable with exactly the same values in all observations, i suggest renaming the variables while using a normal merge:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want_merge;
	merge have updates(rename=(Subject2=Subject1 Procedure2=Procedure1));
	by Subject1 Procedure1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Both datasets have to be sorted by Subject and Procedure.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 05:17:47 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-04-07T05:17:47Z</dc:date>
    <item>
      <title>How to join two columns from one table to a different table based matching criteria</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-join-two-columns-from-one-table-to-a-different-table/m-p/637964#M19089</link>
      <description>&lt;P&gt;Hi, I am trying to join the columns "Type2" and "Measurement2" from table "Update" to the table "Have". I want the columns to align where column "Subject1" in table "Have" matches column "Subject2" in table "update", and column "Procedure1" in table "Have" matches column "Procedure2" in table "Update". Thank you in advance.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
	input Subject1 Type1 :$12. Date1 &amp;amp;:anydtdte. Procedure1 :$12. Measurement1;
	format date yymmdd10.;
	datalines;

500   Initial    15 AUG 2017      Invasive    20 
500   Initial    15 AUG 2017     Surface      35   
428   Initial     3 JUL 2017     Outer        10 
765   Initial     20 JUL 2019     Other       19  
610   Initial     17 Mar 2018     Invasive    17 
;

data Update;
	input Subject2 Type2 :$12. Date2 &amp;amp;:anydtdte. Procedure2 :$12. Measurement2;
	format date yymmdd10.;
	datalines;

500   Followup   15 AUG 2018     Invasive     54 
428   Followup    15 AUG 2018      Outer      29 
765   Seventh     3 AUG 2018      Other       13 
500   Followup    3 JUL 2018      Surface     98 
610   Third       20 AUG 2019     Invasive    66  
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 00:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-join-two-columns-from-one-table-to-a-different-table/m-p/637964#M19089</guid>
      <dc:creator>AshJuri</dc:creator>
      <dc:date>2020-04-07T00:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two columns from one table to a different table based matching criteria</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-join-two-columns-from-one-table-to-a-different-table/m-p/637987#M19091</link>
      <description>&lt;P&gt;With a SQL join:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
    input Subject1 Type1 :$12. Date1 &amp;amp;:anydtdte. Procedure1 :$12. Measurement1;
    format date1 yymmdd10.;
    datalines;

500   Initial    15 AUG 2017      Invasive    20 
500   Initial    15 AUG 2017     Surface      35   
428   Initial     3 JUL 2017     Outer        10 
765   Initial     20 JUL 2019     Other       19  
610   Initial     17 Mar 2018     Invasive    17 
;

data Updt;
    input Subject2 Type2 :$12. Date2 &amp;amp;:anydtdte. Procedure2 :$12. Measurement2;
    format date2 yymmdd10.;
    datalines;

500   Followup   15 AUG 2018     Invasive     54 
428   Followup    15 AUG 2018      Outer      29 
765   Seventh     3 AUG 2018      Other       13 
500   Followup    3 JUL 2018      Surface     98 
610   Third       20 AUG 2019     Invasive    66  
;

proc sql;
create table want as
select have.*, updt.*
from have, updt
where subject1=subject2 and procedure1=procedure2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Apr 2020 03:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-join-two-columns-from-one-table-to-a-different-table/m-p/637987#M19091</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-07T03:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to join two columns from one table to a different table based matching criteria</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/How-to-join-two-columns-from-one-table-to-a-different-table/m-p/637991#M19092</link>
      <description>&lt;P&gt;If you don't insist on having two variable with exactly the same values in all observations, i suggest renaming the variables while using a normal merge:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want_merge;
	merge have updates(rename=(Subject2=Subject1 Procedure2=Procedure1));
	by Subject1 Procedure1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Both datasets have to be sorted by Subject and Procedure.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 05:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/How-to-join-two-columns-from-one-table-to-a-different-table/m-p/637991#M19092</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-04-07T05:17:47Z</dc:date>
    </item>
  </channel>
</rss>

