<?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: Exclude values from one table based on another table in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/407491#M26152</link>
    <description>&lt;P&gt;I got here late, but I would do it this like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
create table mart.NOex
as select a.*
from mart.validoutcome a
left join mart.exclusions1 b
on a.patid = b.patid
having missing(b.patid)
order by a.patid, a.index_dt;
quit;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Oct 2017 22:15:02 GMT</pubDate>
    <dc:creator>ProcWes</dc:creator>
    <dc:date>2017-10-25T22:15:02Z</dc:date>
    <item>
      <title>PROC SQL: Exclude values from one table based on another table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/406555#M26107</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using EG to run code and have two separate datasets: one with my subset-population of interest and a second with the entire dataset of people with exclusion criteria codes.&amp;nbsp; How can I exclude any patient IDs that are in the exclusion criteria?&amp;nbsp; I've been trying different ways to no avail.&amp;nbsp; Here was my most recent attempt but I can't use the WHERE in PROC SQL.&amp;nbsp; What is the best code to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;create&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mart.NOex&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;as&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;select&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#008080"&gt;a.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;*, b.patid&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mart.validoutcome a, mart.exclusions1 b&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.patid NE b.patid &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;order&lt;/FONT&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.patid, a.index_dt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 15:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/406555#M26107</guid>
      <dc:creator>Dsquared</dc:creator>
      <dc:date>2017-10-25T15:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with 2 databases</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/406569#M26111</link>
      <description>&lt;P&gt;You can do this with a sub select. You don't give data so here's an example using SASHELP.CARS where I want all makes by manufacturers who DON'T make SUVs (the suv table is your exclusion list)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table suv
	as select distinct make
	from sashelp.cars
	where type="SUV";
quit;

proc sql;
	create table others as 
	select * from sashelp.cars
	where make not in
		(select make
		 from suv);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Oct 2017 14:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/406569#M26111</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-10-23T14:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with 2 databases</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/407068#M26126</link>
      <description>&lt;P&gt;Use the NOT IN() condition in your WHERE clause:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table mart.NOex as 
select *
from mart.validoutcome
where patid not in (select patid from mart.exclusions1)
order by patid, index_dt;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Oct 2017 20:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/407068#M26126</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-10-24T20:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL with 2 databases</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/407345#M26145</link>
      <description>&lt;P&gt;Thanks so much to the both of you.&amp;nbsp; The NOT IN was a lifesaver!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 15:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/407345#M26145</guid>
      <dc:creator>Dsquared</dc:creator>
      <dc:date>2017-10-25T15:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Exclude values from one table based on another table</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/407491#M26152</link>
      <description>&lt;P&gt;I got here late, but I would do it this like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
create table mart.NOex
as select a.*
from mart.validoutcome a
left join mart.exclusions1 b
on a.patid = b.patid
having missing(b.patid)
order by a.patid, a.index_dt;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Oct 2017 22:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/PROC-SQL-Exclude-values-from-one-table-based-on-another-table/m-p/407491#M26152</guid>
      <dc:creator>ProcWes</dc:creator>
      <dc:date>2017-10-25T22:15:02Z</dc:date>
    </item>
  </channel>
</rss>

