<?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: Alternative data/proc step for sql not exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552610#M153614</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222166"&gt;@bhu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your table2 and table3 are SAS WORK tables this might be a useful approach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table work.insert as
	select * from work.table2 a
	where not exists (
		select * from work.table3 b
		where a.v1=b.v1 and a.v2=b.v2
	);
quit;

proc append
	base = sqllib.table1
	data = work.insert;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 20 Apr 2019 08:05:57 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2019-04-20T08:05:57Z</dc:date>
    <item>
      <title>Alternative data/proc step for sql not exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552554#M153599</link>
      <description>&lt;P&gt;I have a condition where I have to use "where not exists" in proc sql. The problem with this is, it runs extremely fast inside the SQL server, but this is very very slow using SAS. So I need an alternative for it in SAS.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
insert into table1 
select * from table2 a
where not exists
(
select * from table3 b
where a.cond1=b.cond1 and a.cond2=b.cond2
)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:00:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552554#M153599</guid>
      <dc:creator>bhu</dc:creator>
      <dc:date>2019-04-19T23:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative data/proc step for sql not exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552558#M153600</link>
      <description>&lt;P&gt;Use passthrough code to execute the query&amp;nbsp;on the server might be best approach then.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If table3 is in a remote DBMS then there is going to be a lot of overhead and if the other two tables are also on the server then passthrough to execute in the DBMS would really be the way to go.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2019 23:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552558#M153600</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-19T23:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative data/proc step for sql not exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552561#M153601</link>
      <description>Thanks for reply.&lt;BR /&gt;Case I. Yes pass through is faster but I could not get the number of rows inserted.&lt;BR /&gt;Case II. I have a situation where I ended with pulling these datasets inside the WORK folder.</description>
      <pubDate>Fri, 19 Apr 2019 23:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552561#M153601</guid>
      <dc:creator>bhu</dc:creator>
      <dc:date>2019-04-19T23:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative data/proc step for sql not exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552610#M153614</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222166"&gt;@bhu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your table2 and table3 are SAS WORK tables this might be a useful approach:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table work.insert as
	select * from work.table2 a
	where not exists (
		select * from work.table3 b
		where a.v1=b.v1 and a.v2=b.v2
	);
quit;

proc append
	base = sqllib.table1
	data = work.insert;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Apr 2019 08:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Alternative-data-proc-step-for-sql-not-exists/m-p/552610#M153614</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-04-20T08:05:57Z</dc:date>
    </item>
  </channel>
</rss>

