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 (September 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 18 Sep 2002 18:02:50 -0400
Reply-To:   "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Dorfman, Paul" <Paul.Dorfman@BCBSFL.COM>
Subject:   Re: selecting records
Comments:   To: Sebastien Dube <Sebastien.Dube@MCGILL.CA>
Content-Type:   text/plain; charset=iso-8859-1

Sebastian,

Rephrasing, it can be said that from each (v1 v3 v4) key-group, you want to output only the first v2 key-group, since if there is more than one, the v2 values in the subsequent v2 key-groups will be different from that in the first v2 key-group. If the condition is met, then in the code below the outer DoW-loop iterates once, else - more than once, hence:

data a ; input recno (v1 v2 v3) (: $char1.) 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 ; run ;

proc sort equals ; by v1 v3 v4 ; run ;

data b ( drop = cnt4 ) ; do cnt4 = 1 by 1 until (last.v4) ; do until (last.v2) ; set a ; by v1 v3 v4 v2 notsorted ; if cnt4 = 1 then output ; end ; end ; run ;

EQUALS option is added to SORT to preserve the original relative order of V2 occurrences in the records, and NOTSORTED - to prevent it from causing trouble in the last step.

Kind regards, ================== Paul M. Dorfman Jacksonville, FL ==================

> -----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 >

Blue Cross Blue Shield of Florida, Inc., and its subsidiary and affiliate companies are not responsible for errors or omissions in this e-mail message. Any personal comments made in this e-mail do not reflect the views of Blue Cross Blue Shield of Florida, Inc.


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