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 (October 1996, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 2 Oct 1996 15:18:30 -0400
Reply-To:     "Tian, Ching" <TianC@MEDIMMUNE.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         "Tian, Ching" <TianC@MEDIMMUNE.COM>
Subject:      Re: howto: delete/keep obs with 2 byvars
Comments: To: "Steven B. Isbell" <sbi9477@TNTECH.EDU>

Try this:

PROC SORT data=test; BY X DESCENDING Y;

data test1; retain count; set test; by x descending y;

if first.x then count=0;

count+1;

if count<=5 then output;

run;

Ching Tian Medimmune Inc.

>---------- >From: Steven B. Isbell[SMTP:sbi9477@TNTECH.EDU] >Sent: Friday, September 27, 1996 12:11 PM >To: Multiple recipients of list SAS-L >Subject: howto: delete/keep obs with 2 byvars > >Data are sorted by two variables, X and Y. I want to output only the 5 >largest values of Y for each X. The number of observations of Y for each >X is not the same. The following does <i>not</i> work: > >PROC SORT; > BY X DESCENDING Y; >IF FIRST.X THEN DO; > IF _N_>5 THEN DELETE; >END; >IF LAST.X THEN OUTPUT; > >Anyone know how to do this? >


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