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