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 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 1 Jul 2008 17:35:07 -0500
Reply-To:     Mary <mlhoward@avalon.net>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mary <mlhoward@AVALON.NET>
Subject:      Re: Update info in data set based on other data set
Content-Type: text/plain; charset="iso-8859-1"

Jan,

Ian is correct that I'm not accounting for possible duplicate values in the lookup table.

Here's a nested join solution, using the second table as a lookup; I'll think about whether I can improve upon it, but it does seem to work.

-Mary

data test1;

infile cards;

input id visit mmddyy10.;

format visit mmddyy10.;

cards;

1 06/12/2008

1 06/13/2008

3 06/14/2008

;

data test2

infile cards;

input id visit mmddyy10.;

format visit mmddyy10.;

cards;

1 06/12/2008

1 06/12/2008

3 06/13/2008

;

proc sql;

select test1.*, 1 as flag

from test1

where test1.id in (select test2.id

from test2 where test1.id=test2.id

and test1.visit=test2.visit)

union

select test1.*, 0 as flag

from test1

where test1.id not in (select test2.id

from test2 where test1.id=test2.id

and test1.visit=test2.visit);

quit;

run;


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