Date: Tue, 16 Jul 2002 09:48:25 -0400
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Organization: MindSpring Enterprises
Subject: Re: link between two datasets...
Content-Type: text/plain;
"tin-shun-jimmy chan" <jimmy.chan@HEC.CA> wrote in message
news:bbbd8bedaf.bedafbbbd8@hec.ca...
> Hello,
>
> I want to know how to do something in one dataset according to some
> conditions in another dataset.
>
> For example, if nb > 200 for the i-th year in one dataset, then delete
> all the observations of the whole i-th year in another dataset.
>
> dataset 1
>
> year nb
> 1970 195
> 1980 205
> ...
>
> dataset 2
> year score
> 1970 20
> 1970 30
> 1970 35
> 1980 10
> 1980 15
> 1980 06
> ...
>
> So I want to delete all the 1980's observations in dataset 2 according
> to dataset 1.
>
> Thanks a lot.
>
> Jim
You can use SQL to delete rows in place
You can use DATA;MODIFY; to delete rows in place
You can use DATA;SET; to create new dataset with rows deleted
Here is SQL
delete from TWO where year in (select year from ONE where nb > 200);
If you want to simply process the data through your 'nb>200' perspective
(while leaving original data intact), consider using a view
create view TWO_with_NB_LE_200 as
select * from TWO
where year in (select year from ONE where NB<=200)
--
Richard A. DeVenezia
http://www.devenezia.com/downloads/sas/macros/#sas2xls
Use Perl to create an Excel file containing one worksheet per SAS dataset