<?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: Proc SQL - Two tables have the same name, but are in different libraries in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Two-tables-have-the-same-name-but-are-in-different/m-p/21486#M4548</link>
    <description>Hi:&lt;BR /&gt;
  This may be the place where the use of AS in the FROM clause might help you out:&lt;BR /&gt;
[pre]&lt;BR /&gt;
libname perm 'c:\temp';&lt;BR /&gt;
data perm.class;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  if age ge 14;&lt;BR /&gt;
run;&lt;BR /&gt;
            &lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select a.name, b.age, b.height&lt;BR /&gt;
    from perm.class as a, sashelp.class as b&lt;BR /&gt;
    where a.name=b.name;&lt;BR /&gt;
quit;&lt;BR /&gt;
    &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Wed, 28 May 2008 21:37:55 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2008-05-28T21:37:55Z</dc:date>
    <item>
      <title>Proc SQL - Two tables have the same name, but are in different libraries</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Two-tables-have-the-same-name-but-are-in-different/m-p/21485#M4547</link>
      <description>I have a table named "salary" in a library named "lib1" and another table named "salary" in a library named "lib2".  "Salary" in "lib1" contains the columns "id" and "payrate".  "Salary" in "lib2" also contains the columns "id" and "payrate".  The values in the columns of the "salary" table in "lib1" are not identical to the values in the columns of the "salary" table in "lib2".&lt;BR /&gt;
&lt;BR /&gt;
In the 'select' clause of the code below, it is not specified which "salary" table is being referred to in "salary.id" and "salary.payrate".  Also, in the 'where' clause, it is not specified which "salary" tables are being referred to in "salary.id=salary.id".&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select salary.id, salary.payrate&lt;BR /&gt;
from lib1.salary, lib2.salary&lt;BR /&gt;
where salary.id=salary.id;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Does anyone know how I can specify that the "salary.id" in the select clause comes from "salary" in the "lib1" library and "salary.payrate" comes from "salary" in the "lib2" library?  Also, how do I specify that the first "salary.id" in the 'where' clause specifies "salary.id" in "lib1" and the second "salary.id" specifies "salary.id" in "lib2"?&lt;BR /&gt;
&lt;BR /&gt;
I tried the following code, but it didn't work and I got error messages:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select lib1.salary.id, lib2.salary.payrate&lt;BR /&gt;
from lib1.salary, lib2.salary&lt;BR /&gt;
where lib1.salary.id=lib2.salary.id;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
I could rename the tables so they have different names, but I am curious to know if it is possible for the sql to work with the tables having the same name.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Wed, 28 May 2008 21:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Two-tables-have-the-same-name-but-are-in-different/m-p/21485#M4547</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-28T21:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Two tables have the same name, but are in different libraries</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Two-tables-have-the-same-name-but-are-in-different/m-p/21486#M4548</link>
      <description>Hi:&lt;BR /&gt;
  This may be the place where the use of AS in the FROM clause might help you out:&lt;BR /&gt;
[pre]&lt;BR /&gt;
libname perm 'c:\temp';&lt;BR /&gt;
data perm.class;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  if age ge 14;&lt;BR /&gt;
run;&lt;BR /&gt;
            &lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select a.name, b.age, b.height&lt;BR /&gt;
    from perm.class as a, sashelp.class as b&lt;BR /&gt;
    where a.name=b.name;&lt;BR /&gt;
quit;&lt;BR /&gt;
    &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 28 May 2008 21:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Two-tables-have-the-same-name-but-are-in-different/m-p/21486#M4548</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-05-28T21:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Two tables have the same name, but are in different libraries</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Two-tables-have-the-same-name-but-are-in-different/m-p/21487#M4549</link>
      <description>Thanks, Cynthia!</description>
      <pubDate>Thu, 29 May 2008 13:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-SQL-Two-tables-have-the-same-name-but-are-in-different/m-p/21487#M4549</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-05-29T13:44:16Z</dc:date>
    </item>
  </channel>
</rss>

