| Date: | Tue, 9 May 2000 16:34:58 -0400 |
| Reply-To: | Yunlong Ma <yuman@HSC.VCU.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Yunlong Ma <yuman@HSC.VCU.EDU> |
| Organization: | VIPBG, VCU |
| Subject: | Re: find non-consecutive numbers? |
| Content-Type: | text/plain; charset=gb2312 |
Hi Rob,
Is one 'do until' loop enough?
Best,
Yunlong
"Workman, Robert" wrote:
> Try this.
>
> Rob Workman
>
> data stuff;
> input studid grade;
> cards;
> 001 1
> 001 2
> 001 3
> 001 4
> 001 5
> 002 1
> 002 2
> 002 4
> 002 5
> 003 1
> 003 3
> 003 4
> 003 5
> ;
> run;
>
> data morestff;
> do until (eof);
> ii = 0;
> do until (last.studid);
> ii + 1;
> set stuff end = eof;
> by studid;
> if grade = ii then output;
> end;
> end;
> run;
>
> *** output ***
> The SAS System
>
> OBS II STUDID GRADE
>
> 1 1 1 1
> 2 2 1 2
> 3 3 1 3
> 4 4 1 4
> 5 5 1 5
> 6 1 2 1
> 7 2 2 2
> 8 1 3 1
>
> > -----Original Message-----
> > From: James Yang [SMTP:jamesy99@HOTMAIL.COM]
> > Sent: Tuesday, May 09, 2000 12:50 PM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: find non-consecutive numbers?
> >
> > I have following sas dataset SSD with two variables. E.g:
> >
> > StudID Grade
> > 001 1
> > 001 2
> > 001 3
> > 001 4
> > 001 5
> > 002 1
> > 002 2
> > 002 4
> > 002 5
> > 003 1
> > 003 3
> > 003 4
> > 003 5
> > That means, each student should attend all 5 grades(grade: 1 2 3 4 5)).
> > But
> > some students skip some grades. For this example, student 002 just attend
> > 1
> > 2 4 5. and student 003 just 1 3 4 5. Right now, what I want to do is: for
> > a
> > student with missing grades, delete all additional grades. So for Student
> > 002, grade 4 5 will be deleted and 1 2 will be kept. For student 003, 3
> > 4
> > 5 will be deleted and 1 will be kept. How to make this? If any expert can
> > provide your valuable advice, it would be highly appreciated!
> >
> > Regards,
> > James
> > ________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
|