<?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 - Removing list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622044#M182938</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one large dataset A, and one small dataset B.&amp;nbsp;&amp;nbsp; Both dataset contain some same&amp;nbsp;sample names, birthdates, tests.&amp;nbsp;&amp;nbsp;&amp;nbsp; As long as both&amp;nbsp;sets have same names / dates / tests,&amp;nbsp;&amp;nbsp; I would like to remove those from set A ( the bigger dataset).&amp;nbsp;&amp;nbsp; Please advice how.&amp;nbsp;&amp;nbsp; Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Getting just the variables you mention:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table want as
   select name, birthdate, tests from dataseta
   except
   select name, birthdate, tests from datasetb
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;If there are other variables in set A that you need you need to joint that back to set A&lt;/P&gt;</description>
    <pubDate>Mon, 03 Feb 2020 20:53:49 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-02-03T20:53:49Z</dc:date>
    <item>
      <title>Proc SQL - Removing list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622035#M182935</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one large dataset A, and one small dataset B.&amp;nbsp;&amp;nbsp; Both dataset contain some same&amp;nbsp;sample names, birthdates, tests.&amp;nbsp;&amp;nbsp;&amp;nbsp; As long as both&amp;nbsp;sets have same names / dates / tests,&amp;nbsp;&amp;nbsp; I would like to remove those from set A ( the bigger dataset).&amp;nbsp;&amp;nbsp; Please advice how.&amp;nbsp;&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 20:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622035#M182935</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-02-03T20:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Removing list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622042#M182937</link>
      <description>&lt;P&gt;proc sql;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select name, birthdate, test&lt;/P&gt;
&lt;P&gt;&amp;nbsp; from a&lt;/P&gt;
&lt;P&gt;except&lt;/P&gt;
&lt;P&gt;select name, birthdate, test&lt;/P&gt;
&lt;P&gt;&amp;nbsp; from b;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;should do it.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 20:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622042#M182937</guid>
      <dc:creator>mbuchecker</dc:creator>
      <dc:date>2020-02-03T20:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Removing list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622044#M182938</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one large dataset A, and one small dataset B.&amp;nbsp;&amp;nbsp; Both dataset contain some same&amp;nbsp;sample names, birthdates, tests.&amp;nbsp;&amp;nbsp;&amp;nbsp; As long as both&amp;nbsp;sets have same names / dates / tests,&amp;nbsp;&amp;nbsp; I would like to remove those from set A ( the bigger dataset).&amp;nbsp;&amp;nbsp; Please advice how.&amp;nbsp;&amp;nbsp; Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Getting just the variables you mention:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table want as
   select name, birthdate, tests from dataseta
   except
   select name, birthdate, tests from datasetb
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;If there are other variables in set A that you need you need to joint that back to set A&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 20:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622044#M182938</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-02-03T20:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Removing list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622045#M182939</link>
      <description>&lt;P&gt;Dataset A contains 50 columns, and dataset B contains 3 columns.&amp;nbsp; My final result is dataset A contains 50 columns&amp;nbsp;WITHOUT dataset B.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 21:02:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622045#M182939</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-02-03T21:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Removing list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622102#M182972</link>
      <description>&lt;P&gt;Here two ways for doing this.&lt;/P&gt;
&lt;P&gt;If you don't create datasetA within your program then I wouldn't overwrite this table but would create a copy of it (another table) with the rows removed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create sample data */
data datasetA datasetB(keep=name birthdate tests);
  set sashelp.class;
  birthdate=today(); 
  format birthdate date9.;
  tests=1;
  output datasetA;
  if mod(_n_,2)=0 then output datasetB;
run;

/* delete rows from datasetA in place
   - deletes rows LOGICALLY only
   - Does NOT reduce table size
   - maintains table attributes like indexes
*/
proc sql;
  delete from datasetA as A
  where exists
    ( select * from datasetB as B
      where 
        a.name=b.name
        and a.birthdate=b.birthdate
        and a.tests=b.tests
    )
   ;
quit;

proc contents data=datasetA;
run;quit;

/* re-create the table with matching rows removed 
   - fully re-creates the table
   - reduces table size
   - will not maintain other table attributes like indexes
*/
data datasetA;
  if _n_=1 then 
    do;
      dcl hash h1(dataset:'datasetB');
      h1.defineKey('name','birthdate','tests');
      h1.defineDone();
    end;
  set datasetA;
  if h1.check()=0 then delete;
run;

proc contents data=datasetA;
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2020 22:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622102#M182972</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-02-04T22:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - Removing list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622126#M182987</link>
      <description>&lt;P&gt;Here is how to do in hash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
input names $ birthdates:date9. tests $;
format birthdates date9.;
cards;
AA 09Jan2010 X
BB 10Jan2010 Y
CC 11Jan2010 X
DD 12Jan2010 X
;
run;

data have2;
input names $ birthdates:date9. tests $;
format birthdates date9.;
cards;
AA 09Jan2010 X
BB 10Jan2010 Y
;
run;

data want;
set have1;
if _n_=1 then do;
	declare hash rc (dataset: 'work.have2');
	rc.DefineKey ( 'names','birthdates','tests' ) ;
	rc.DefineDone () ; 
end;
if rc.find() =0 then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Feb 2020 06:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Removing-list/m-p/622126#M182987</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2020-02-04T06:53:29Z</dc:date>
    </item>
  </channel>
</rss>

