LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 29 Oct 2008 20:08:13 -0400
Reply-To:   Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:   Re: Proc sort Nodupkey..but I want to keep the first. (dot) of the unique variables by the date var.
Comments:   To: SUBSCRIBE SAS-L Anonymous <rharvey3015@GMAIL.COM>
Content-Type:   text/plain; charset=ISO-8859-1

If I correctly understand what you want, then I think the following will achieve the desired result. Of course, if ID is irrelevant, simply remove it from both of the sorts:

proc sort data=xx; by id rcode pcode pr keydt; run; proc sort data=xx out=want nodupkey; by id rcode pcode pr; run;

HTH, Art --------- On Wed, 29 Oct 2008 19:00:02 -0400, SUBSCRIBE SAS-L Anonymous <rharvey3015@GMAIL.COM> wrote:

>I have a data set in which I have duplicates (rcode, pcodes, and prov). I >want a create a new table in which these are deduped, but retaining the >first time they were experienced as unique by (keydate). I cant use proc >sort nodupkey because I need to include keydate in the sort, and will >yield no dups by that particular date. If I don’t use the keydate the >sort will then sort by rcode, pcode and prov; and will not yield the first >time the unique combination was observed. > > >data xx; >format keydt date. rcode $4. pcode $5.; >input ID keydt :date. rcode pcode pr; >cards; >8001 20-Jan-06 634 J0886 26 >8001 20-Jan-06 636 J1270 26 >8001 20-Jan-06 821 90999 26 >8001 06-Feb-06 634 J0886 26 >8001 06-Feb-06 636 J1270 26 >8001 06-Feb-06 821 90999 26 >8001 23-Feb-06 634 J0886 26 >8001 23-Feb-06 636 J1270 26 >8001 23-Feb-06 821 90935 26 >8001 03-Mar-06 634 J0886 26 >8001 03-Mar-06 636 J1270 26 >8001 03-Mar-06 821 90935 26 >8001 10-Apr-06 636 J1270 26 >8001 10-Apr-06 821 90935 26 >8001 20-Apr-06 634 J0886 26 >8001 20-Apr-06 636 J1270 26 >8001 20-Apr-06 821 90935 26 >8001 13-May-06 270 A4657 26 >8001 13-May-06 634 J0886 26 >8001 13-May-06 636 J1270 26 >8001 13-May-06 821 90935 26 >8001 16-May-06 270 A4657 26 >8001 16-May-06 634 J0886 26 >8001 16-May-06 636 J1270 26 >8001 16-May-06 821 90935 26 >8001 22-May-06 634 J0886 26 >8001 22-May-06 636 J1270 26 >8001 22-May-06 821 90935 26 >8001 07-Jun-06 634 J0886 26 >8001 07-Jun-06 636 J1270 26 >8001 07-Jun-06 821 90935 26 >8001 20-Jun-06 634 J0886 26 >8001 20-Jun-06 636 J1270 26 >8001 20-Jun-06 821 90935 26 >8001 07-Jul-06 270 A4657 26 >8001 07-Jul-06 634 J0886 26 >8001 07-Jul-06 636 J1270 26 >8001 07-Jul-06 821 90935 26 >8001 14-Jul-06 634 J0886 26 > >; >run;


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