| Date: | Mon, 10 Jul 2000 10:16:35 -0700 |
| Reply-To: | Ya Huang <ya.huang@AGOURON.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Ya Huang <ya.huang@AGOURON.COM> |
| Subject: | Re: Help needed! |
| Content-Type: | text/plain; charset=us-ascii |
James, try the following:
data xx;
input studID $ GRADE;
cards;
01 90
01 96
01 70
01 50
01 70
02 80
02 70
02 90
02 76
;
data xx;
set xx;
retain flag1 flag2;
by studid;
if first.studid then do; flag1=0; flag2=0; end;
if grade =70 then do; flag1=1; flag2+1; end;
if flag2 gt 0 then flag2+1;
if flag1 and flag2 > 2 then delete;
options nocenter;
proc print;
run;
---------------------------------------
OBS STUDID GRADE FLAG1 FLAG2
1 01 90 0 0
2 01 96 0 0
3 01 70 1 2
4 02 80 0 0
5 02 70 1 2
James Yang wrote:
>
> I have following dataset: J1 with 2 vars:
>
> StudID GRADE
> 01 90
> 01 96
> 01 70
> 01 50
> 01 70
> 02 80
> 02 70
> 02 90
> 02 76
>
> What I want to do now is: for a given student, all records after the first
> time grade=70 are deleted. That is, for this specific example, following
> will be my expected output dataset:
>
> StudID GRADE
> 01 90
> 01 96
> 01 70
> 02 80
> 02 70
>
> How can make this efficiently? Any advice is appreciated in advance.
>
> James
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
|