LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (September 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 24 Sep 2009 19:38:09 +0200
Reply-To:   Daniel Fernández <fdezdan@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Daniel Fernández <fdezdan@GMAIL.COM>
Subject:   Re: subset
Comments:   To: Joe Matise <>
In-Reply-To:   <>
Content-Type:   text/plain; charset=ISO-8859-1

I code it following your explicit names.... 8:).


DATA SUBSET; SET DATAALL (WHERE=(X='F')); RUN; proc sort data=DATAALL;by x; run; proc sort data=SUBSET ;by x; run; DATA DATAALL_without_subset; merge DATAALL (in=a) SUBSET (in=b); by x; if a and NOT b; run;


2009/9/24 Joe Matise <>: > data datanew; > merge dataall(in=a) datasub(in=b); > by (whatever); > if not b; > run; > > obviously filling in (whatever) with your unique ID [and, both must be > sorted or indexed by that]. > > PROC SQL can also trivially produce the same results if you prefer that: > create table datanew as select * from dataall A where not exists (select 1 > from datasub S where A.uniqueid=S.uniqueid); > or > create table datanew as select * from dataall A except select * from datasub > S; *note that 'except' does work in SAS SQL but does not hilight as a > reserved word in the editor - mildly annoying!; > > Examples using sashelp.class and 'name' as the unique ID: > > data guys; > set sashelp.class; > if sex='M'; > run; > > proc sql; > create table girls1 as select * from sashelp.class except select * from > guys; > create table girls2 as select * from sashelp.class C where not exists > (select 1 from guys G where; > quit; > > data girls3; > merge sashelp.class(in=a) guys(in=b); > by name; > if not b; > run; > > > -Joe > > On Thu, Sep 24, 2009 at 12:20 PM, Jeff <> wrote: > >> datasub is subset of dataall and there is no duplicate in dataall. >> How can I get all record in dataall which not in datasub (dataall-datasub)? >> >> Thanks. >> Jeff >> >

Back to: Top of message | Previous page | Main SAS-L page