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 (July 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 16 Jul 2002 09:22:14 -0400
Reply-To:   Magnus Mengelbier <magnus.mengelbier@FERRING.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Magnus Mengelbier <magnus.mengelbier@FERRING.COM>
Subject:   Re: link between two datasets...
Comments:   To: Jimmy Chan <jimmy.chan@HEC.CA>

hello jim

here is one way... using a merge. i can think of another using a macro approach depending on how you the end result should look.

HTH

Magnus

/* ---------- code... briefly tested on 8.2 ------------------- */

/* -- You original data sets -- */ data work.dataset1; input year 1-4 nb 8-12; cards; 1970 195 1980 205 ; run;

data work.dataset2; input year 1-4 score 8-12; cards; 1970 20 1970 30 1970 35 1980 10 1980 15 1980 06 ; run;

/* -- one delete list coming up -- */ data work.deletelist(keep=year delete_me); set work.dataset1; if (nb > 200); /* Set delete flag based on your nb > 200 */ delete_me = 1; run;

/* add on the delete flags to your data and delete */ proc sql noprint; create table work.result as select a.*, b.delete_me from work.dataset2 a left join work.deletelist b on (a.year=b.year) where (delete_me ne 1); /* <<<<---- delete your unwanted --- */ quit;

/* ---------- end of code... briefly tested on 8.2 ------------------- */

On Mon, 15 Jul 2002 19:22:23 -0400, tin-shun-jimmy chan <jimmy.chan@HEC.CA> wrote:

>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


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