Date: Wed, 18 Sep 2002 16:16:22 -0400
Reply-To: Howard_Schreier@ITA.DOC.GOV
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Howard_Schreier@ITA.DOC.GOV
Subject: Re: selecting records
Content-Type: text/plain; charset=ISO-8859-1
But suppose there were a seventh record with the same Vn values as the
third record:
7 A B A 10
As I interpret the problem, it too should be deleted. So I would use the
following code for the third step:
data w2;
set w;
by v1 v3 v4;
if first.v4 then v2match=v2;
if v2match=v2;
retain v2match;
drop v2match;
run ;
On Wed, 18 Sep 2002 14:49:08 -0400, Ian Whitlock <WHITLOI1@WESTAT.COM>
wrote:
>Sebastian,
>
>Here is code based on diskin.dennis@KENDLE.COM suggestion to sort the file.
>
>data w ; input
>rec v1 $ v2 $ v3 $ v4 $ ; cards ;
> 1 A A A 10
> 2 A A A 10
> 3 A B A 10
> 4 B A B 20
> 5 B B B 40
> 6 C A B 50
>;
>
>proc sort data = w ;
> by v1 v3 v4 rec ;
>run ;
>
>data w2 ;
> set w ;
> lv1 = lag ( v1 ) ;
> lv2 = lag ( v2 ) ;
> lv3 = lag ( v3 ) ;
> lv4 = lag ( v4 ) ;
>
> if v1=lv1 and v3=lv3 and v4=lv4 then
> do ;
> if v2 ^= lv2 then delete ;
> end ;
>run ;
>
>proc sort data = w2 ;
> by rec ;
>run ;
>
>IanWhitlock@westat.com
>
>-----Original Message-----
>From: Sebastien Dube [mailto:Sebastien.Dube@MCGILL.CA]
>Sent: Wednesday, September 18, 2002 1:57 PM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: selecting records
>
>
>Sorry for the confusion. You were right, somthing was wrong in my
>question. Let me rephrase that.
>
>My data would look like this (I switched the symbols...)
>
> rec# v1 v2 v3 v4
> 1 A A A 10
> 2 A A A 10
> 3 A B A 10
> 4 B A B 20
> 5 B B B 40
> 6 C A B 50
>
>looking specifically at the first 3 records, I wish to discard #3
>because for v1, v3 and v4 it has the same values as record #1 AND a
>different value in V2 (than record #1). However, I wish to keep record
>#2 because the value in v2 is the same as for record #1. In sum, record
>#3 is the only one I wish to delete for this dataset.
>
>Thank you again.
>Sébastien
>
>
>
>--
>Sébastien Dubé
>Planning Analyst
>
>University Planning Office
>James Administration Bldg. rm: 633
>McGill University
>845 Sherbrooke W St.
>Montreal, Quebec
>H3A 2T5
>
>Phone: (514)398-7072
>Fax: (514)398-7358
|