<?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 records in one table but not in another table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/records-in-one-table-but-not-in-another-table/m-p/930711#M366162</link>
    <description>&lt;P&gt;I have 4 tables as&amp;nbsp;&lt;/P&gt;&lt;P&gt;table - 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;table- 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;table - 3&lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;so need a report like records in one but not in 2nd and not in 3rd&lt;/P&gt;&lt;P&gt;Output table&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID col1 col2 col3&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;y&amp;nbsp; &amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y&amp;nbsp;&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;n&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;n&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2024 19:49:50 GMT</pubDate>
    <dc:creator>kajal_30</dc:creator>
    <dc:date>2024-06-03T19:49:50Z</dc:date>
    <item>
      <title>records in one table but not in another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/records-in-one-table-but-not-in-another-table/m-p/930711#M366162</link>
      <description>&lt;P&gt;I have 4 tables as&amp;nbsp;&lt;/P&gt;&lt;P&gt;table - 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;table- 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;table - 3&lt;/P&gt;&lt;P&gt;ID&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;so need a report like records in one but not in 2nd and not in 3rd&lt;/P&gt;&lt;P&gt;Output table&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID col1 col2 col3&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp;y&amp;nbsp; &amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y&amp;nbsp;&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;n&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; y&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;n&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; n&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 19:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/records-in-one-table-but-not-in-another-table/m-p/930711#M366162</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-06-03T19:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: records in one table but not in another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/records-in-one-table-but-not-in-another-table/m-p/930715#M366164</link>
      <description>&lt;P&gt;Just use a simple MERGE.&amp;nbsp; You can use the IN= datsaet option to name a variable that indicates if a particular dataset has contributed to the resulting observation.&amp;nbsp; But that variable will be temporary.&amp;nbsp; So just assign the value to another variable that will be permanent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;first let's convert your listings into actual datasets:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1 ;
  input ID @@;
cards;
1 2 3 4
;

data table2;
  input ID @@;
cards;
2 3 4 5
;

data table3;
  input ID @@;
cards;
1 2 4 6
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now just merge and save the IN= variable values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge table1(in=in1) table2(in=in2) table3(in=in3);
  by id;
  col1=in1;
  col2=in2;
  col3=in3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    ID    col1    col2    col3

 1      1      1       0       1
 2      2      1       1       1
 3      3      1       1       0
 4      4      1       1       1
 5      5      0       1       0
 6      6      0       0       1
&lt;/PRE&gt;
&lt;P&gt;If you would like COL1 to COL3 to print as Y/N or YES/NO then just define a format and attach it to the variables.&amp;nbsp; Demonstration:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value yn 1='Y' 0='N';
value yesno 1='Yes' 0='No';
run;

data want;
  merge table1(in=in1) table2(in=in2) table3(in=in3);
  by id;
  col1=in1;
  col2=in2;
  col3=in3;
  format col2 yn. col3 yesno.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    ID    col1    col2    col3

 1      1      1      N      Yes
 2      2      1      Y      Yes
 3      3      1      Y      No
 4      4      1      Y      Yes
 5      5      0      Y      No
 6      6      0      N      Yes

&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Jun 2024 20:02:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/records-in-one-table-but-not-in-another-table/m-p/930715#M366164</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-06-03T20:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: records in one table but not in another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/records-in-one-table-but-not-in-another-table/m-p/933346#M367075</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2024 16:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/records-in-one-table-but-not-in-another-table/m-p/933346#M367075</guid>
      <dc:creator>kajal_30</dc:creator>
      <dc:date>2024-06-21T16:02:55Z</dc:date>
    </item>
  </channel>
</rss>

