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 (April 2012, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 14 Apr 2012 04:01:37 +0000
Reply-To:     "Zdeb, Michael S" <mzdeb@ALBANY.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Zdeb, Michael S" <mzdeb@ALBANY.EDU>
Subject:      Re: Identifying duplicates when certain condition
In-Reply-To:  <4F88A42E.6090902@gmail.com>
Content-Type: text/plain; charset="Windows-1252"

hi ... if you want all the duplicate observations in one data set, I don't think that this ...

Proc Sort Data= Have Out=Unique Dupout=Dupes NoDupKey; By Current_Date Account_Number ; Run;

works since it will put one of the duplicate observations from each duplicate group into data set UNIQUE (DUPES will be missing those observations)

if you want all the dupes in one data set, you can use a data step as others suggested

if you have V9.3, you can try ...

proc sort data=have out=all_dups uniqueout=all_unique nouniquekey; by current_date account_number; run;

Mike Zdeb U@Albany School of Public Health One University Place (Room 119) Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

________________________________________ From: SAS(r) Discussion [SAS-L@LISTSERV.UGA.EDU] on behalf of Mark Miller [mdhmiller@GMAIL.COM] Sent: Friday, April 13, 2012 6:09 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Identifying duplicates when certain condition

Alternatively, do it in one step by modifying the SORT

Proc Sort Data = Have Out = Unique Dupout = Dupes NoDupKey;

By Current_Date Account_Number ; Run;

Have -- still has original data Unique -- has unique keys Dupes -- duplicates

...Mark Miller

On 4/13/2012 2:22 PM, toby dunn wrote: > Proc Sort > Data = Have ; > By Current_Date Account_Number ; > Run ; > > > Data Need ; > Set Have ; > By Current_Date Account_Number ; > > If Not ( First.Account_Number and Last.Account_Number ) ; > > Run ; > > > > Once you have this you have a data set with duplicate account numbers within each value of Current_Date. > > > Toby Dunn > > > If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain. > > “Any idiot can face a crisis—it’s day to day living that wears you out” > ~ Anton Chekhov > > > >> Date: Fri, 13 Apr 2012 17:12:00 -0400 >> From: neilfrnnd@GMAIL.COM >> Subject: Identifying duplicates when certain condition >> To: SAS-L@LISTSERV.UGA.EDU >> >> Hi collegues, >> >> I have a data set like this. I want to see if there are duplicate values >> in variable "Account_number" when the current_date=28FEB2010. >> >> data a; >> Informat current_date date9.; >> Input Current_date Account_number $ 11-15; >> Format current_date date9.; >> datalines; >> 31JUL2010 10500 >> 31JUL2010 10500 >> 31JUL2010 200 >> 31JUL2010 300 >> 31JUL2010 400 >> 31JUL2010 2400 >> 31JUL2010 2400 >> >> 28FEB2010 10500 >> 28FEB2010 10500 >> 28FEB2010 200 >> 28FEB2010 200 >> 28FEB2010 200 >> 28FEB2010 2400 >> 28FEB2010 100 >> ; >> run; >> >> >> I tried below but doesn't work. Could you please help. >> >> >> Proc sort data=a out=temp; >> by account_number; >> run; >> >> >> data temp2; >> set temp; >> by account_number; >> if not (first.account_number and last.account_number) then output; >> where current_date ='31JUL2010'; >> run; >> >> Help is greately apprecaited. >> Mirisage >


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