Date: Thu, 19 Apr 2001 12:17:17 -0600
Reply-To: Frank Liu <fql@TIMBERLINE.CA>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Frank Liu <fql@TIMBERLINE.CA>
Organization: Timberline Forest Inventory Consultants Ltd.
Subject: Re: duplicate records
Content-Type: text/plain; charset=us-ascii
You may try this:
Proc sort data=sample;
by subjid time_sec; /* you do not have subjid in your sample data but I
guess you need it*/
data sample1;
set sample;
by subjid time_sec;
if last.time_sec;
run;
It usually works fine for me.
Frank
"Karen Olson, Ph.D." wrote:
> I have some data files from a video coding system that creates records
> with two fields of interest: a code and a time. The time value is
> hours:minutes:seconds:frames and frames are 30 per second. In the end,
> I want a file with the time in seconds. I have most of the conversion
> done but am stuck with one problem. Rounding the original time value to
> the nearest second sometimes gives me >1 record with the same time. I
> want to keep only the LAST of these duplicates. All the tricks I've
> tried (e.g. proc sort nodupkeys; by subjid time_sec;) have given me the
> FIRST of the duplicates and eliminated the rest. I tried 'descending
> time_sec' and various things in data steps (e.g. the lag function) but
> do not end up with what I want.
>
> Here's some sample data: time_sec infcode
> 25 Inon
> 25 Ineu
> 30 Inon
> 41 Ipos
> 44 Inon
> 44 Ineu
> 45 Inon
>
> I get: 25 Inon
> 30 Inon
> 41 Ipos
> 44 Inon
> 45 Inon
>
> But I want: 25 Ineu
> 30 Inon
> 41 Ipos
> 44 Ineu
> 45 Inon
>
> Any suggestions? Thanks so much in advance.
>
> Karen Olson
> Children's Hospital, Boston
> karen.olson@tch.harvard.edu
--
Frank Q. Liu, Ph.D.
Resource Analyst
Timberline Forest Inventory Consultants Ltd.
Suite 315, 10357-109th Street
Edmonton, Alberta
T5J 1N3
tel (780) 425-8826
fax (780) 428-6782
email fql@timberline.ca