|
Proc SQL ;
Create Table Need ( Drop = Diff ) As
Select A.ID , A.Date As Date1 ,
B.Date As Date2 ,
ABS( A.Date - B.Date ) As Diff
From One As A ,
Two As B
Where A.ID = B.ID
Group By A.ID , A.Date
Having Min( Diff ) = Diff ;
Quit ;
Toby Dunn
"Don't bail. The best gold is at the bottom of barrels of crap."
Randy Pausch
"Be prepared. Luck is where preparation meets opportunity."
Randy Pausch
> Date: Mon, 16 Nov 2009 10:59:06 -0500
> From: harrypotterdhf@EARTHLINK.NET
> Subject: Comparing Dates From 2 Different Files
> To: SAS-L@LISTSERV.UGA.EDU
>
> I have SAS 8.21 installed at my site. I am comparing dates from customers
> from 2 different files. I want to take the customer date from the 2nd file
> closest to the date in the 1st file. A customer in the 1st file might have 2
> different dates but I want the date in the 2nd file closest to each:
>
> Example Input:
>
> File 1
>
> Customer ID date1
> 1 01/06/09
> 1 02/07/09
> 2 02/01/09
>
> File 2
>
> Customer ID date2
> 1 03/07/09
> 1 04/09/09
> 1 04/30/09
> 2 03/06/09
> 2 07/07/09
>
> Desired Output:
>
> Customer date1 date2
> 1 01/06/09 03/07/09
> 1 02/07/09 03/07/09
> 2 02/01/09 03/06/09
_________________________________________________________________
Bing brings you maps, menus, and reviews organized in one place.
http://www.bing.com/search?q=restaurants&form=MFESRP&publ=WLHMTAG&crea=TEXT_MFESRP_Local_MapsMenu_Resturants_1x1
|