<?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 do I join tables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-join-tables/m-p/935043#M367643</link>
    <description>Thank you so much!  My SAS programming skills are rusty from years of not using SAS.  I have to re-learn SAS in a hurry!  Really appreciate this.</description>
    <pubDate>Mon, 08 Jul 2024 20:06:12 GMT</pubDate>
    <dc:creator>elained</dc:creator>
    <dc:date>2024-07-08T20:06:12Z</dc:date>
    <item>
      <title>how do I join tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-join-tables/m-p/935035#M367640</link>
      <description>&lt;P&gt;I have 2 tables that I need to join.&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;Patients&amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;LabResults&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want everyone in the Patients table.&lt;/P&gt;
&lt;P&gt;I only want LabResults that match records in the Patients table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The identifier that both tables contain is &lt;STRONG&gt;PatientID&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;How do I match all records in the &lt;STRONG&gt;Patients&lt;/STRONG&gt; table to those that have the same&lt;STRONG&gt; PatientID&lt;/STRONG&gt; in the &lt;STRONG&gt;LabResults&lt;/STRONG&gt; table?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 19:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-join-tables/m-p/935035#M367640</guid>
      <dc:creator>elained</dc:creator>
      <dc:date>2024-07-08T19:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: how do I join tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-join-tables/m-p/935042#M367642</link>
      <description>&lt;P&gt;This is called a MERGE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge patients lab_results;
  by patientid;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to exclude lab results that are not actually from patients (how did they get into your database then?) you can use the IN= dataset option to create temporary indicator variables to indicate if the the given dataset is contributing to the current observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge patients(in=in1) lab_results;
  by patientid;
  if not in1 then do;
    if first.patientid then put 'ERROR: ' patientid= 'found in LABRESULTS but not in PATIENTS.';
    delete;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Jul 2024 20:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-join-tables/m-p/935042#M367642</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-08T20:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: how do I join tables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-join-tables/m-p/935043#M367643</link>
      <description>Thank you so much!  My SAS programming skills are rusty from years of not using SAS.  I have to re-learn SAS in a hurry!  Really appreciate this.</description>
      <pubDate>Mon, 08 Jul 2024 20:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-join-tables/m-p/935043#M367643</guid>
      <dc:creator>elained</dc:creator>
      <dc:date>2024-07-08T20:06:12Z</dc:date>
    </item>
  </channel>
</rss>

