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 (November 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 16 Nov 2009 12:49:35 -0600
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Comparing Dates From 2 Different Files
Comments: To: David Friedman <harrypotterdhf@earthlink.net>
In-Reply-To:  <200911161752.nAGHIYFd011920@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

Something like this should work. No promise about speed, but it should function.

data have; informat date1 MMDDYY8.; format date1 mmddyy8.; input CustomerID date1; datalines; 1 01/06/09 1 02/07/09 1 03/08/09 1 04/08/09 1 04/15/09 1 05/01/09 2 02/01/09 2 06/01/09 2 08/02/09 ;;;; run; data to_merge; informat date1 MMDDYY8.; format date1 mmddyy8.; input CustomerID date1; datalines; 1 03/07/09 1 04/09/09 1 04/30/09 2 03/06/09 2 07/07/09 ;;;; run;

proc sql; create table want as select h.customerID, h.date1, min(t.date1) as new_date from have h, ( select m.customerid,m.date1,h.date1 as cur_date from have h, to_merge m where m.customerid=h.customerid and m.date1 >= h.date1 ) t where h.customerid=t.customerid and h.date1=t.cur_date group by h.customerID, h.date1 having min(t.date1-h.date1); quit;

-Joe

On Mon, Nov 16, 2009 at 11:52 AM, David Friedman < harrypotterdhf@earthlink.net> wrote:

> Thanks, Toby. I forgot to add the stipulation that the date from the 2nd > file can not be earlier than the date from the 1st file. >


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