<?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 Matching and Non-matching in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-and-Non-matching/m-p/30717#M5880</link>
    <description>dataset A has id's with multiple zipcodes.and dataset B can have multiple zipcodes for an id.&lt;BR /&gt;
how to create matching dataset if:&lt;BR /&gt;
atleast one of the zip match for an id from dataset A match with dataset B.&lt;BR /&gt;
for instance id 40288,  95126 matches.so we need to show only that id and zip from dataset A and Zip_cd from dataset B.&lt;BR /&gt;
&lt;BR /&gt;
Nonmmatching dataset:&lt;BR /&gt;
if none of the zip from dataset A for an id match with dataset B.for instance 15123.&lt;BR /&gt;
&lt;BR /&gt;
dataset A:&lt;BR /&gt;
&lt;BR /&gt;
 id                                     zip&lt;BR /&gt;
40228	                      93728	   &lt;BR /&gt;
40228	                      93901	 &lt;BR /&gt;
40228                             94403&lt;BR /&gt;
40228                             95126  &lt;BR /&gt;
15123                             30106&lt;BR /&gt;
&lt;BR /&gt;
dataset B&lt;BR /&gt;
  id                                 zip_cd&lt;BR /&gt;
40228                              95126 &lt;BR /&gt;
15123                              30141</description>
    <pubDate>Tue, 09 Nov 2010 15:16:35 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2010-11-09T15:16:35Z</dc:date>
    <item>
      <title>Matching and Non-matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-and-Non-matching/m-p/30717#M5880</link>
      <description>dataset A has id's with multiple zipcodes.and dataset B can have multiple zipcodes for an id.&lt;BR /&gt;
how to create matching dataset if:&lt;BR /&gt;
atleast one of the zip match for an id from dataset A match with dataset B.&lt;BR /&gt;
for instance id 40288,  95126 matches.so we need to show only that id and zip from dataset A and Zip_cd from dataset B.&lt;BR /&gt;
&lt;BR /&gt;
Nonmmatching dataset:&lt;BR /&gt;
if none of the zip from dataset A for an id match with dataset B.for instance 15123.&lt;BR /&gt;
&lt;BR /&gt;
dataset A:&lt;BR /&gt;
&lt;BR /&gt;
 id                                     zip&lt;BR /&gt;
40228	                      93728	   &lt;BR /&gt;
40228	                      93901	 &lt;BR /&gt;
40228                             94403&lt;BR /&gt;
40228                             95126  &lt;BR /&gt;
15123                             30106&lt;BR /&gt;
&lt;BR /&gt;
dataset B&lt;BR /&gt;
  id                                 zip_cd&lt;BR /&gt;
40228                              95126 &lt;BR /&gt;
15123                              30141</description>
      <pubDate>Tue, 09 Nov 2010 15:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-and-Non-matching/m-p/30717#M5880</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-11-09T15:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: Matching and Non-matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-and-Non-matching/m-p/30718#M5881</link>
      <description>Would this work?&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data A;&lt;BR /&gt;
input id zip;&lt;BR /&gt;
datalines;&lt;BR /&gt;
40228 93728 &lt;BR /&gt;
40228 93901 &lt;BR /&gt;
40228 94403&lt;BR /&gt;
40228 95126 &lt;BR /&gt;
15123 30106&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data B;&lt;BR /&gt;
input id zip_cd;&lt;BR /&gt;
datalines;&lt;BR /&gt;
40228 95126 &lt;BR /&gt;
15123 30141 &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* find matching rows via data step merge */&lt;BR /&gt;
proc sort data=a;&lt;BR /&gt;
 by id zip;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=b;&lt;BR /&gt;
 by id zip_cd;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data matching;&lt;BR /&gt;
 merge a (in=a) b (rename=(zip_cd=zip) in=b);&lt;BR /&gt;
 by id zip;&lt;BR /&gt;
 if a and b;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/* find non matching rows */&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 create table nonmatching as&lt;BR /&gt;
 select a.id, a.zip, b.id as b_id, b.zip_cd, sum(a.zip = b.zip_cd) as flag&lt;BR /&gt;
 from a, b&lt;BR /&gt;
 where a.id = b.id &lt;BR /&gt;
 group by a.id&lt;BR /&gt;
 having flag = 0;&lt;BR /&gt;
quit;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 09 Nov 2010 16:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-and-Non-matching/m-p/30718#M5881</guid>
      <dc:creator>Daryl</dc:creator>
      <dc:date>2010-11-09T16:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Matching and Non-matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-and-Non-matching/m-p/30719#M5882</link>
      <description>Thanks.I worked.</description>
      <pubDate>Wed, 10 Nov 2010 17:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-and-Non-matching/m-p/30719#M5882</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2010-11-10T17:28:08Z</dc:date>
    </item>
  </channel>
</rss>

