Date: Thu, 11 Sep 1997 16:53:31 -0400
Reply-To: tteng@on.bell.ca
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Qiang Teng (Tom)" <tteng@ON.BELL.CA>
Organization: Bell Canada
Subject: Re: deleting duplicates
Content-Type: text/plain; charset=us-ascii
Lund, Peter wrote:
>
> If the data is already sorted by id, you can use the BY statement to
> keep the first record for each id value. For example:
>
> data undupped;
> set dupped;
> by id;
>
> if first.id then output;
> run;
>
> If the incoming dataset is not sorted by id, you'll need to sort it
> first.
>
> HTH-
> Pete Lund
> WA State Office of Financial Management
> peter.lund@ofm.wa.gov
>
> ----------
> From: Lynn Nicole Lethbridge[SMTP:lynnl@IS.DAL.CA]
> Sent: Thursday, September 11, 1997 9:38 AM
> To: SAS-L@UGA.CC.UGA.EDU
> Subject: deleting duplicates
>
> Hi there
>
> I have data where there are duplicates of observations. I'd like to get
> rid of the duplicates which appear together. Included with the data are
> unique identifiers for each observation. So for example in the
> following:
>
> obs id
> 1 1
> 2 2
> 3 3
> 4 3
> 5 3
>
> I'd like to get rid of obs 4 and 5.
>
> The repeats always follow directly after the original observation which
> I
> keep.
>
> Thanks so much for any help.
>
> Lynn
Lynn:
Try this:
Proc sort data=xxx nodupkey; by id; run;
|