<?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: Join on or in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80482#M23155</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, Vincent's solution should improve things a lot. Furthermore, if no record in Emp_List has both &lt;STRONG&gt;employee&lt;/STRONG&gt; AND &lt;STRONG&gt;legacyemployee&lt;/STRONG&gt; then replacing UNION by UNION ALL will improve things still further.&lt;/P&gt;&lt;P&gt;Syntax wise, you must remove the semicolons after &lt;STRONG&gt;a.employee,&lt;/STRONG&gt; they don't belong there, and you can remove the &lt;STRONG&gt;select * from ( )&lt;/STRONG&gt; wrappers, they are not required.&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2013 14:11:15 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2013-07-16T14:11:15Z</dc:date>
    <item>
      <title>Join on or</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80479#M23152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having an issue with the join below as it takes for ever to run, any suggestions would be great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Source_Lights as&lt;/P&gt;&lt;P&gt;select datepart(a.date)format Date9. as date,a.employee,a.count(a.timestamp) as Totals, sum(a.Valid) as Valid&lt;/P&gt;&lt;P&gt;from Lights a inner join Emp_List b&lt;/P&gt;&lt;P&gt;on (a.employee = b.employee or a.employee = b.legacyemployee)&lt;/P&gt;&lt;P&gt;and a.date = b.date&lt;/P&gt;&lt;P&gt;group by a.date, a.employee;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Without the or a.employee = b.legacyemployee it works but when this is added it just spolls and still has yet to complete after an hour.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fred&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 11:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80479#M23152</guid>
      <dc:creator>fred_major</dc:creator>
      <dc:date>2013-07-16T11:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Join on or</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80480#M23153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't think of an explanation as to why the ON statement would be processed different from a where join but have you tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;from lights a, emp_list b&lt;/P&gt;&lt;P&gt;where (a.employee=b.employee or a.employee=b.legacyemployee) and a.date=b.date&lt;/P&gt;&lt;P&gt;group by a.date, a.employee;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Else, you can always try to merge 2 subqueries to kill that or statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table source_light as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select * from (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select datepart(a.date)format Date9. as date,a.employee,a.count(a.timestamp) as Totals, sum(a.Valid) as Valid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from Lights a inner join Emp_List b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on (a.employee = b.employee)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and a.date = b.date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by a.date, a.employee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; union&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select * from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select datepart(a.date)format Date9. as date,a.employee,a.count(a.timestamp) as Totals, sum(a.Valid) as Valid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from Lights a inner join Emp_List b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on (a.employee = b.legacyemployee)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and a.date = b.date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by a.date, a.employee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure either will really improve the computing speed but until a better answer comes up, it is worth testing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vincent&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*edit* removed the bad semi columns as depicted by PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80480#M23153</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-07-16T12:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: Join on or</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80481#M23154</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does b.employee have a value if b.legacyemployee is populated?&amp;nbsp; My thinking is that if b.employee is missing in these instances then putting 'a.employee=coalesce(b.employee,b.legacyemployee)' may speed things up a bit.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 12:56:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80481#M23154</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2013-07-16T12:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Join on or</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80482#M23155</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, Vincent's solution should improve things a lot. Furthermore, if no record in Emp_List has both &lt;STRONG&gt;employee&lt;/STRONG&gt; AND &lt;STRONG&gt;legacyemployee&lt;/STRONG&gt; then replacing UNION by UNION ALL will improve things still further.&lt;/P&gt;&lt;P&gt;Syntax wise, you must remove the semicolons after &lt;STRONG&gt;a.employee,&lt;/STRONG&gt; they don't belong there, and you can remove the &lt;STRONG&gt;select * from ( )&lt;/STRONG&gt; wrappers, they are not required.&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:11:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80482#M23155</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-07-16T14:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Join on or</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80483#M23156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Vince this worked like a charm after removing the semicolons as PG advised.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perfect&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fred&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80483#M23156</guid>
      <dc:creator>fred_major</dc:creator>
      <dc:date>2013-07-16T14:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: Join on or</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80484#M23157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks PG for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fred&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Join-on-or/m-p/80484#M23157</guid>
      <dc:creator>fred_major</dc:creator>
      <dc:date>2013-07-16T14:39:57Z</dc:date>
    </item>
  </channel>
</rss>

