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 <snoopy369@gmail.com>
In-Reply-To:   <b7a7fa630909241028o6e65d599t5b29e260fe12d6bf@mail.gmail.com>
Content-Type:   text/plain; charset=ISO-8859-1

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

DATA DATAALL; INPUT X $ N; CARDS; E 2 W 1 F 4 ; RUN;

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;

Daniel

2009/9/24 Joe Matise <snoopy369@gmail.com>: > 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 C.name =G.name); > 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 <zhujp98@gmail.com> 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