<?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 Proc sql join in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-join/m-p/52824#M14542</link>
    <description>There are 5 tables:&lt;BR /&gt;
1. Year05d: 5 variables + 2 keys: zip naics&lt;BR /&gt;
2. Year06d: 5 variables + 2 keys: zip naics&lt;BR /&gt;
3. Year05t: 3 variables + key: zip&lt;BR /&gt;
4. Year06t 3 variables + key: zip&lt;BR /&gt;
5. look-up table: 2 variables: naics sic&lt;BR /&gt;
&lt;BR /&gt;
I need one table that is unique at zip+naics level and contains all observations and all the variables from all 5 tables.&lt;BR /&gt;
With data step the logic was as following:&lt;BR /&gt;
1. merge Year05d Year06d by zip naics&lt;BR /&gt;
2. merge Year05t Year06t by zip&lt;BR /&gt;
3. merge step1 and step2&lt;BR /&gt;
4. merge step3 and look-up table by naics &lt;BR /&gt;
&lt;BR /&gt;
how do i do that with sql in one step?</description>
    <pubDate>Wed, 08 Oct 2008 20:35:38 GMT</pubDate>
    <dc:creator>Yulka</dc:creator>
    <dc:date>2008-10-08T20:35:38Z</dc:date>
    <item>
      <title>Proc sql join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-join/m-p/52824#M14542</link>
      <description>There are 5 tables:&lt;BR /&gt;
1. Year05d: 5 variables + 2 keys: zip naics&lt;BR /&gt;
2. Year06d: 5 variables + 2 keys: zip naics&lt;BR /&gt;
3. Year05t: 3 variables + key: zip&lt;BR /&gt;
4. Year06t 3 variables + key: zip&lt;BR /&gt;
5. look-up table: 2 variables: naics sic&lt;BR /&gt;
&lt;BR /&gt;
I need one table that is unique at zip+naics level and contains all observations and all the variables from all 5 tables.&lt;BR /&gt;
With data step the logic was as following:&lt;BR /&gt;
1. merge Year05d Year06d by zip naics&lt;BR /&gt;
2. merge Year05t Year06t by zip&lt;BR /&gt;
3. merge step1 and step2&lt;BR /&gt;
4. merge step3 and look-up table by naics &lt;BR /&gt;
&lt;BR /&gt;
how do i do that with sql in one step?</description>
      <pubDate>Wed, 08 Oct 2008 20:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-join/m-p/52824#M14542</guid>
      <dc:creator>Yulka</dc:creator>
      <dc:date>2008-10-08T20:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql join</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-join/m-p/52825#M14543</link>
      <description>I would start with something like this.  Keep in mind that there's only one way to get all the observations and also be unique at the zip+naics level and that is if your first two tables only have one observation per zip+naics level and your second two tables only have one observatikon per zip level.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table all as&lt;BR /&gt;
   select *&lt;BR /&gt;
   from year05d a, year06d b, year05t c, year06t d, look-up table e&lt;BR /&gt;
   where a.zip = b.zip&lt;BR /&gt;
      and a.naics = b.naics&lt;BR /&gt;
      and c.zip = d.zip&lt;BR /&gt;
      and c.zip = a.zip&lt;BR /&gt;
      and a.naics = e.naics;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]

Message was edited by: 1162</description>
      <pubDate>Fri, 10 Oct 2008 17:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-join/m-p/52825#M14543</guid>
      <dc:creator>1162</dc:creator>
      <dc:date>2008-10-10T17:40:24Z</dc:date>
    </item>
  </channel>
</rss>

