<?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: Extracting observations which are not common in a variable present in two datsets. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/560405#M10459</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;for the help, working flawlessly.&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2019 08:59:41 GMT</pubDate>
    <dc:creator>hiteshchauhan1</dc:creator>
    <dc:date>2019-05-21T08:59:41Z</dc:date>
    <item>
      <title>Extracting observations which are not common in a variable present in two datsets.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559615#M10367</link>
      <description>&lt;P&gt;So, the question i'm about to ask is something i'm trying for the first time in sas. Below is what i want to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two data-sets which have a variable which is common in both. Now that variable has some observation which are common in both the data-sets but also there are some values which are not common. Now, i want the list of those variables which are present in one and not in other for both the data-sets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i can't think of any proc sql or any other statement/function that can help me achieve what i want. Please help me with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 10:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559615#M10367</guid>
      <dc:creator>hiteshchauhan1</dc:creator>
      <dc:date>2019-05-17T10:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting observations which are not common in a variable present in two datsets.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559618#M10368</link>
      <description>Could you please provide a sample data</description>
      <pubDate>Fri, 17 May 2019 10:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559618#M10368</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-17T10:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting observations which are not common in a variable present in two datsets.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559623#M10369</link>
      <description>&lt;P&gt;Several options:&lt;/P&gt;
&lt;P&gt;data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=table1;
by var1;
run;

proc sort data=table2;
by var1;
run;

data exclusions;
merge
  table1 (in=t1 keep=var1)
  table2 (in=t2 keep=var1)
;
by var1;
if t1 and not t2;
if last.t1; /* avoids duplicates */
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table exclusions as
select distinct table1.var1
from table1
where var1 not in (select distinct table2.var1 from table2)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Depending on the size of table2, you could also consider to create a "yes/no" format from it, and use that while reading table1 to decide if observations are kept.&lt;/P&gt;
&lt;P&gt;Or one could create a hash object from table2 (needs approx. the same amount of memory as the format method).&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 10:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559623#M10369</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-17T10:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting observations which are not common in a variable present in two datsets.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559625#M10370</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;i tried the proc sql one and it worked smoothly. Though, i nees\d a little clarification on this, the output i will get will be observations of var1 from table1 which are not found in table2. Am i getting it right?&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2019 11:18:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559625#M10370</guid>
      <dc:creator>hiteshchauhan1</dc:creator>
      <dc:date>2019-05-17T11:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting observations which are not common in a variable present in two datsets.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559673#M10374</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/271996"&gt;@hiteshchauhan1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;i tried the proc sql one and it worked smoothly. Though, i nees\d a little clarification on this, the output i will get will be observations of var1 from table1 which are not found in table2. Am i getting it right?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use a UNION operation between two "directional" selections to get both sides. EXCEPT is another way to do the basic selection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table exclusions as
   (select distinct table1.var1
      from table1
   except
   select distinct table2.var1 from table2)

   union

   (select distinct table21.var1
      from table2
   except
   select distinct table1.var1 from table1)
   ;
quit;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 May 2019 14:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/559673#M10374</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-17T14:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting observations which are not common in a variable present in two datsets.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/560405#M10459</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;for the help, working flawlessly.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 08:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Extracting-observations-which-are-not-common-in-a-variable/m-p/560405#M10459</guid>
      <dc:creator>hiteshchauhan1</dc:creator>
      <dc:date>2019-05-21T08:59:41Z</dc:date>
    </item>
  </channel>
</rss>

