From: MarySAS on 19 Apr 2010 15:25 Thanks to anyone who can help me with this. I am working with two large datasets. The first table, JAN, is huge, 140million records, distinct by PersonID, EventDate and Hour. PersonID EventDate Hour EventAmt The second table, MASTER, has 2 fields RateCode and Cycle that I need to lookup and put onto the first file. A person can have different cycle and rate codes for different days or range of days. The Second table has 1 million records, distinct by PersonID, FromDate and ToDate: PersonID FromDate ToDate RateCode Cycle Im sure you could do a SQL statement and get from table B values where the IDs match and the FromDate <= EventDate and ToDate >= EventDate, but I think that a HASH would be much quicker. But, Im very new to HASH and am trying to figure out how to set this up. Heres what I have so far: / *****************************************************************************************/ Data JanNew; Set Jan; If _n_ = 0 then set Master; If _n_ = 1 then do; Declare hash MAS (Dataset : master, multidata: Y, Ordered: A) Rc=mas.definekey (PersonId); Rc=mas.definedata (fromdt, todate, ratecode, cycle); RC=mas.definedone(); Do until (eof); Set Jan end=eof; RC=mas.find (); If RC = 0 then do; If FromDate <= EventDate <= ToDate then ?????????? / *****************************************************************************************/ Im lost as to how to check the dates to make sure I am looking at the right lookup records, then get the variables back from the hash object and output the Event record.
From: MarySAS on 20 Apr 2010 17:06 Thanks Patrick!!! This was very helpful. I appreciate the response. Thanks again. --Mary
From: MarySAS on 20 Apr 2010 17:07 Thanks Michelle!! Between your response and another one, I learned what I needed to do to get my hash working. I appreciate your response to my question. Thanks again, Mary
|
Pages: 1 Prev: HASH Help Needed Next: stopping at first event: simple but need help |