Date: Fri, 23 May 2008 09:52:18 -0700
Reply-To: "Ramsey, Julia" <Julia.Ramsey@CXTOWN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Ramsey, Julia" <Julia.Ramsey@CXTOWN.COM>
Subject: Re: how to associate item sold dates and inventory dates
Content-Type: text/plain; charset="us-ascii"
How about something like this?
input id selldate date9.;
input id invdate date9.;
create table lastinventory as select distinct
t1.selldate format date9.,
max(t2.invdate) as lastinv format date9.
from itemsales t1, inventory t2
where t1.id = t2.id and
t1.selldate > t2.invdate
group by t1.id
order by t1.id;
id selldate lastinv
1 20MAY2007 14MAY2007
2 27MAY2007 22MAY2007
3 29MAY2007 20MAY2007
4 30MAY2007 25MAY2007
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Friday, May 23, 2008 9:29 AM
Subject: how to associate item sold dates and inventory dates
A problem that ought to be easy to solve but I can't think of answer
I have 2 datasets, A lists items by ID number and, for each item, the
date it was sold.
B lists dates on which the story took an inventory of items (but just
the date of the inventory, no list of items in stock at the time).
I want to identify, for each item sold, the date of the last inventory
prior to the date it was sold, and add that inventory date to the
record for the item. I presume DATA steps would be used, but perhaps