<?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: Removing observations based on two variable after matching with other table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366141#M87067</link>
    <description>&lt;P&gt;Please sort a and b datasets on st_code and id and then merge&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge a(in=a) b(in=b);
by st_code id;
if b and not a;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 12 Jun 2017 13:30:19 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2017-06-12T13:30:19Z</dc:date>
    <item>
      <title>Removing observations based on two variable after matching with other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366136#M87063</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to remove observation from A which are present in B;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;input st_code Addr$ Name$ ID;&lt;BR /&gt;datalines;&lt;BR /&gt;06111 kota atul 552927&lt;BR /&gt;08888 delh gaur 552927&lt;BR /&gt;13089 pune pink 666666&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data b;&lt;BR /&gt;input st_code ID;&lt;BR /&gt;datalines;&lt;BR /&gt;06111 552927&lt;BR /&gt;13089 552927&lt;BR /&gt;13135 552927&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 13:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366136#M87063</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-06-12T13:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations based on two variable after matching with other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366140#M87066</link>
      <description>&lt;P&gt;What variables do you want this selection to depend on? Both st_code and ID?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input st_code Addr$ Name$ ID;
datalines;
06111 kota atul 552927
08888 delh gaur 552927
13089 pune pink 666666
;
run;

data b;
input st_code ID;
datalines;
06111 552927
13089 552927
13135 552927
;
run;

proc sort data = a;
	by ID st_code;
run;

proc sort data = b;
	by ID st_code;
run;

data a;
	merge a b(in=in_b);
	by ID st_code;
	if not in_b then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 13:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366140#M87066</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-12T13:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations based on two variable after matching with other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366141#M87067</link>
      <description>&lt;P&gt;Please sort a and b datasets on st_code and id and then merge&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge a(in=a) b(in=b);
by st_code id;
if b and not a;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 13:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366141#M87067</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-12T13:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations based on two variable after matching with other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366144#M87070</link>
      <description>&lt;P&gt;Is there is any other, I tried this one before but it is not removing all the observation from A, which are present in B (on basis of both variable st_code &amp;amp; ID).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think its due to &amp;nbsp;I've multiple observation of st_code &amp;amp; multiple IDs&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 13:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366144#M87070</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-06-12T13:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations based on two variable after matching with other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366152#M87076</link>
      <description>&lt;P&gt;Please post what you want your final dataset to look like, because the way I see it, the only observation from A, which is also in B (based on both st_code and ID) is the first observation in A, which is removed when you run the code above.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2017 13:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366152#M87076</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-12T13:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations based on two variable after matching with other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366157#M87079</link>
      <description>&lt;P&gt;proc sql is an alternative&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input st_code Addr$ Name$ ID;
datalines;
06111 kota atul 552927
08888 delh gaur 552927
13089 pune pink 666666
;
run;

data b;
input st_code ID;
datalines;
06111 552927
13089 552927
13135 552927
;
run;

proc sql;
create table test as select distinct a.* from a right join b on a.st_code^=b.st_code and a.id^=b.id having a.id ne .;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 14:07:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366157#M87079</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-12T14:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Removing observations based on two variable after matching with other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366245#M87114</link>
      <description>&lt;P&gt;just another way&lt;/P&gt;
&lt;PRE&gt;proc sql;
create table abc as 
select * from a tbl1
where not exists
               (select * from b tbl2
			   where tbl1.id =tbl2.id
               and tbl1.st_code = tbl2.st_code);
quit;
			 &lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jun 2017 17:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-observations-based-on-two-variable-after-matching-with/m-p/366245#M87114</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-12T17:31:49Z</dc:date>
    </item>
  </channel>
</rss>

