<?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 Adding equivalent of if/then/delete in SQL join in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-equivalent-of-if-then-delete-in-SQL-join/m-p/369718#M275604</link>
    <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a criteria that relies on the output from three joins to be able to execute. So currently, I perform my 3 joins in sql, then add a base sas statement&amp;nbsp;as such:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;set have;&lt;/P&gt;&lt;P&gt;If product in ('MC1', 'MC2') and Status='CLOSED' and balance='' then delete;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of current sql join, if someone has a tip to modify it to add the above?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql; create table final as;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from a left join status_table b&amp;nbsp;&lt;/P&gt;&lt;P&gt;on id=id&lt;/P&gt;&lt;P&gt;inner join balance_table c&lt;/P&gt;&lt;P&gt;on id=id;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(first table A contains PRODUCT) , thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2017 21:48:20 GMT</pubDate>
    <dc:creator>brulard</dc:creator>
    <dc:date>2017-06-22T21:48:20Z</dc:date>
    <item>
      <title>Adding equivalent of if/then/delete in SQL join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-equivalent-of-if-then-delete-in-SQL-join/m-p/369718#M275604</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a criteria that relies on the output from three joins to be able to execute. So currently, I perform my 3 joins in sql, then add a base sas statement&amp;nbsp;as such:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;set have;&lt;/P&gt;&lt;P&gt;If product in ('MC1', 'MC2') and Status='CLOSED' and balance='' then delete;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of current sql join, if someone has a tip to modify it to add the above?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql; create table final as;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from a left join status_table b&amp;nbsp;&lt;/P&gt;&lt;P&gt;on id=id&lt;/P&gt;&lt;P&gt;inner join balance_table c&lt;/P&gt;&lt;P&gt;on id=id;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(first table A contains PRODUCT) , thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 21:48:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-equivalent-of-if-then-delete-in-SQL-join/m-p/369718#M275604</guid>
      <dc:creator>brulard</dc:creator>
      <dc:date>2017-06-22T21:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: Adding equivalent of if/then/delete in SQL join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-equivalent-of-if-then-delete-in-SQL-join/m-p/369720#M275605</link>
      <description>&lt;P&gt;may be something like this. I have not tested this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table final as&lt;/P&gt;
&lt;P&gt;select * from&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(select *&lt;/P&gt;
&lt;P&gt;from a left join status_table b&amp;nbsp;&lt;/P&gt;
&lt;P&gt;on id=id&lt;/P&gt;
&lt;P&gt;inner join balance_table c&lt;/P&gt;
&lt;P&gt;on id=id)a&lt;/P&gt;
&lt;P&gt;where not(&lt;SPAN&gt;product in ('MC1', 'MC2') and Status='CLOSED' and balance='' );&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 22:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-equivalent-of-if-then-delete-in-SQL-join/m-p/369720#M275605</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-06-22T22:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding equivalent of if/then/delete in SQL join</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-equivalent-of-if-then-delete-in-SQL-join/m-p/369725#M275606</link>
      <description>&lt;P&gt;Didn't test it but you should be able to just add a WHERE to your query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table final as 
select *
from a 
left join status_table b 
on id=id
inner join balance_table c
on id=id
WHERE not (product in ('MC1', 'MC2') and Status='CLOSED' and balance='');

QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Jun 2017 22:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-equivalent-of-if-then-delete-in-SQL-join/m-p/369725#M275606</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-22T22:17:32Z</dc:date>
    </item>
  </channel>
</rss>

