<?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: Joining tables: one.id=two.id syntax issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/263977#M51710</link>
    <description>&lt;P&gt;Hi, I think you might find using an alias helpful, e.g.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc sql;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;create table tables.report as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;select *&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;from&amp;nbsp;&amp;nbsp; tables.employee A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;join&amp;nbsp;&amp;nbsp; tables.task__&amp;nbsp;&amp;nbsp; B on a.task_handler = b.group_member;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2016 19:06:28 GMT</pubDate>
    <dc:creator>Pamela_JSRCC</dc:creator>
    <dc:date>2016-04-14T19:06:28Z</dc:date>
    <item>
      <title>Joining tables: one.id=two.id syntax issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/263101#M51482</link>
      <description>&lt;P&gt;I have made a query which creates a table containing employee names, division and area.&lt;/P&gt;&lt;P&gt;-&amp;nbsp;dataset: tables.employee&lt;/P&gt;&lt;P&gt;- employee names&amp;nbsp;variable: group_member&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have made another query which creates a table containing each employee's opened and closed dossiers and the respective time to close said dossiers.&lt;/P&gt;&lt;P&gt;- dataset: tables.task__ (double underscore)&lt;/P&gt;&lt;P&gt;- employee names variable: task_handler&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I wanted to merge both tables into one neat looking table, based on one common variable: employee names. I found this generalized code on the SAS.com website, but I have no idea what the proper syntax is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;General code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE QinBOTH AS
SELECT *
FROM ONE, TWO
WHERE ONE.ID=TWO.ID
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I changed it into this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table tables.report as
select *
from tables.employee, tables.task__
where tables.employee.group_member=tables.task__.task_handler
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunatly simply changing the word "ONE" with the tables.employee and changing the word "TWO" with tables.task__ isn't correct. How would the syntax have to be?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the log by the way:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;3139  proc sql;
3140  create table tables.report as
3141  select *
3142  from tables.employee, tables.task__
3143  where tables.employee.group_member=tables.task__.task_handler
                           -
                           22
                           76
ERROR 22-322: Syntax error, expecting one of the following: ;, !, !!, &amp;amp;, *, **, +, -, /, &amp;lt;, &amp;lt;=,
              &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN, CONTAINS, EQ, EQT, EXCEPT, GE, GET, GROUP, GT, GTT,
              HAVING, IN, INTERSECT, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ORDER,
              OUTER, UNION, ^, ^=, |, ||, ~, ~=.

ERROR 76-322: Syntax error, statement will be ignored.

3144  ;
3145  quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 07:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/263101#M51482</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-12T07:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Joining tables: one.id=two.id syntax issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/263977#M51710</link>
      <description>&lt;P&gt;Hi, I think you might find using an alias helpful, e.g.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc sql;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;create table tables.report as&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;select *&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;from&amp;nbsp;&amp;nbsp; tables.employee A&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;join&amp;nbsp;&amp;nbsp; tables.task__&amp;nbsp;&amp;nbsp; B on a.task_handler = b.group_member;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2016 19:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/263977#M51710</guid>
      <dc:creator>Pamela_JSRCC</dc:creator>
      <dc:date>2016-04-14T19:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Joining tables: one.id=two.id syntax issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/263980#M51712</link>
      <description>SAS doesn't support three or four level names line my other databases do. That's why you need to use aliases, like &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13994"&gt;@Pamela_JSRCC&lt;/a&gt; suggests.</description>
      <pubDate>Thu, 14 Apr 2016 19:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/263980#M51712</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-04-14T19:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Joining tables: one.id=two.id syntax issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/264093#M51758</link>
      <description>&lt;P&gt;Thanks for the feedback.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do understand what both of you imply, however, I kind of fail to see it in a practical situation. Could you perhaps elaborate with a simple example and bold out alias (right vs wrong)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 06:53:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/264093#M51758</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-15T06:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Joining tables: one.id=two.id syntax issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/264095#M51759</link>
      <description>&lt;P&gt;Oh, never mind me. I just finished my morning coffee and Pamela's reply makes absolute sense. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2016 07:00:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Joining-tables-one-id-two-id-syntax-issue/m-p/264095#M51759</guid>
      <dc:creator>Yves_Boonen</dc:creator>
      <dc:date>2016-04-15T07:00:22Z</dc:date>
    </item>
  </channel>
</rss>

