<?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 output selective records in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/output-selective-records/m-p/12792#M1746</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
i have 2 tables &lt;BR /&gt;
tableA with 360 records and 20 variables like fname lname postcode address1 add2 add3 dob  age etc...&lt;BR /&gt;
&lt;BR /&gt;
tableB with  165 records with 3 variables fname lname postcode.&lt;BR /&gt;
&lt;BR /&gt;
if (tableb.lanme=tablea.lanme) and (tableb.postcode=tablea.postdoce)&lt;BR /&gt;
then output tableA.&lt;BR /&gt;
&lt;BR /&gt;
Output tableA should have only matching records with 20 variables &lt;BR /&gt;
I am trying with merge in a, b, if a and b. but i am not getting the correct output.&lt;BR /&gt;
&lt;BR /&gt;
Is there any simple sql or datastep to solve it.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in Advance,&lt;BR /&gt;
Sams</description>
    <pubDate>Mon, 30 Mar 2009 15:57:10 GMT</pubDate>
    <dc:creator>ssas</dc:creator>
    <dc:date>2009-03-30T15:57:10Z</dc:date>
    <item>
      <title>output selective records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/output-selective-records/m-p/12792#M1746</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
i have 2 tables &lt;BR /&gt;
tableA with 360 records and 20 variables like fname lname postcode address1 add2 add3 dob  age etc...&lt;BR /&gt;
&lt;BR /&gt;
tableB with  165 records with 3 variables fname lname postcode.&lt;BR /&gt;
&lt;BR /&gt;
if (tableb.lanme=tablea.lanme) and (tableb.postcode=tablea.postdoce)&lt;BR /&gt;
then output tableA.&lt;BR /&gt;
&lt;BR /&gt;
Output tableA should have only matching records with 20 variables &lt;BR /&gt;
I am trying with merge in a, b, if a and b. but i am not getting the correct output.&lt;BR /&gt;
&lt;BR /&gt;
Is there any simple sql or datastep to solve it.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in Advance,&lt;BR /&gt;
Sams</description>
      <pubDate>Mon, 30 Mar 2009 15:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/output-selective-records/m-p/12792#M1746</guid>
      <dc:creator>ssas</dc:creator>
      <dc:date>2009-03-30T15:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: output selective records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/output-selective-records/m-p/12793#M1747</link>
      <description>here's one way to do it ...&lt;BR /&gt;
&lt;BR /&gt;
Steps 1 &amp;amp; 2 - sort your tables by the fields in common:&lt;BR /&gt;
proc sort data=tableA; by fname lname postcode; run;&lt;BR /&gt;
proc sort data=tableB; by fname lname postcode; run;&lt;BR /&gt;
&lt;BR /&gt;
Step 3 - merge the data and output:&lt;BR /&gt;
data tableC;&lt;BR /&gt;
merge tableA (in=a) tableB (in=b);&lt;BR /&gt;
by fname lname postcode;&lt;BR /&gt;
if a and b then output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The (in=a) and (in=b) are just aliasing datasets.  When you say IF A AND B THEN OUTPUT, you're basically telling it to do an inner join and output only the rows in common.   As a note, if tableB had more than just the common fields, you could DROP the extra columns that you didn't want.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps!</description>
      <pubDate>Mon, 30 Mar 2009 16:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/output-selective-records/m-p/12793#M1747</guid>
      <dc:creator>daveryBBW</dc:creator>
      <dc:date>2009-03-30T16:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: output selective records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/output-selective-records/m-p/12794#M1748</link>
      <description>Thanks for you help&lt;BR /&gt;
sams</description>
      <pubDate>Thu, 02 Apr 2009 15:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/output-selective-records/m-p/12794#M1748</guid>
      <dc:creator>ssas</dc:creator>
      <dc:date>2009-04-02T15:40:31Z</dc:date>
    </item>
  </channel>
</rss>

