<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Dynamic ranges and lookup logic in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202408#M37753</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah I see, logically, I agree with you, although the business rules says otherwise :smileysilly:&lt;/P&gt;&lt;P&gt;I imagine it is in this block the logic will change to include the same day transactions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if inQ then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.find(key:Prod_Group);/*fetch group specific*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; putlog rc=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if rc~=0 or H_Service_Date&amp;lt;=intnx('day',Service_Date,-&amp;amp;LB_Period_Days,'s') then do;/*not found or old entry*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing(of H_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.find(key:0);/*fetch global*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; if rc~=0 or H_Service_Date&amp;lt;=intnx('day',Service_Date,-&amp;amp;LB_Period_Days,'s') then do;/*not found or old entry*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing(of H_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Mar 2015 13:09:37 GMT</pubDate>
    <dc:creator>DangIT</dc:creator>
    <dc:date>2015-03-17T13:09:37Z</dc:date>
    <item>
      <title>Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202395#M37740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table of 'qualified records' for January that looks like:&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;Member_ID Transaction_ID Service_Date Prod_Group &lt;/P&gt;&lt;P&gt;1 123 2014-01-05 1&lt;/P&gt;&lt;P&gt;1 124 2014-01-08 3&lt;/P&gt;&lt;P&gt;2 126 2014-01-07 2&lt;/P&gt;&lt;P&gt;3 128 2014-01-26 5&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have another table of ALL the history of transactions for each member (HistoryTbl) with all the same variables (plus a bunch more which i've suppressed in this example as I don't believe it'll be relevant to the logic). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to pull in a number of variables from HistoryTbl to Table1 based on the following criteria:&lt;/P&gt;&lt;P&gt;Look back 365 days from Service_Date of the transaction in Table1 for the Member_ID&lt;/P&gt;&lt;P&gt;IF the Member has made a transaction in the SAME Prod_Group: grab following variables of the latest transaction in that Prod_Group from the HistoryTbl: Service_Date, Product_ID, etc.&lt;/P&gt;&lt;P&gt;IF no transaction in the same Prod_Group: Get same variables as above, for the most recent Prod_Group transaction. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am unsure of how to approach the programming logic where essentially I am creating dynamic 'look back periods' for each transaction in Table1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help greatly appreciated.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 15:50:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202395#M37740</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-16T15:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202396#M37741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are your dates SAS dates or character variables? The comparison for a number of days is much easier if they are SAS date values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 17:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202396#M37741</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-03-16T17:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202397#M37742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, all SAS Date variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 17:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202397#M37742</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-16T17:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202398#M37743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I do not have the most advanced programming skills but here is the logic I am thinking of, and would love any feedback.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure how to program the per row processing from Table1 but the idea is:&lt;/P&gt;&lt;P&gt;For each row (Row.) do: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. From the HistoryTbl, Select * Where HistoryTbl.Member_ID = Row.Member_ID and HistoryTbl.Transaction_ID NE Row.Transaction_ID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ** This will give me all transactions by that member not including the current transaction being evaluated.&lt;/P&gt;&lt;P&gt;2. Output LAST.Prod_Group from above to get most recent transaction across all Prod_Group for that Member_ID&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;** This will give me the latest transaction by Member by Prod_Group&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;3. Select Row.Transaction_ID merge by Prod_Group to #2 to get variables related to the SAME Prod_Group (rename the array of variables as InProd_[var_name])&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/TD&gt;&lt;TD&gt;** This will give me the latest transaction in the Prod_Group for that Member.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;4. From 3 merge by Member_ID from #2 to get variables related to the LAST Prod_Group (rename the array of variables as LastProd_[var_name])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ** This will give me the latest transaction in Any Prod_Group for that Member.&lt;/P&gt;&lt;P&gt;5. output record to a master table.&lt;/P&gt;&lt;P&gt;END loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this sound reasonable? Here's where i'm unsure of how I can create this macro inside the datastep to process each row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 21:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202398#M37743</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-16T21:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202399#M37744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As you might have guessed, this is a hard problem.&amp;nbsp; I hope to be able to write up something later tonight.&amp;nbsp; In the meantime, let's begin with a few questions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are MEMBER_ID and PROD_GROUP character or numeric?&amp;nbsp; (If numeric, what is the largest value?)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How large is the historical data set?&amp;nbsp; (You may need a lot of memory for this to work, and it may take some time to run.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you allowed to sort the historical data set, and store a copy in the new sorted order?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note, there may be too many complications for me to explain them all.&amp;nbsp; You may want to study up on these topics:&amp;nbsp; creating a format from a SAS data set (that is, the CNTLIN= option on PROC FORMAT), and the POINT= option on the SET statement.&amp;nbsp; More later ....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 21:06:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202399#M37744</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-03-16T21:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202400#M37745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your help on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Member_ID is character, Prod_group is a numeric up to 14.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently writing the script on the first month (january) and will be running it every month after. At January 2014 the Historical dataset is 6000 records, with approx 800 records added monthly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, allowed to sort historical dataset and store a copy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 21:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202400#M37745</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-16T21:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202401#M37746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, even if the data sets grow this should run quickly enough.&amp;nbsp; If you were adding 1M records per month, this might not be best.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The idea is to create a format out of the historic file.&amp;nbsp; Each row of the format translates a combination of MEMBER_ID + PROD_GROUP + a range of dates into the matching observation number in the historic file.&amp;nbsp; So this is just the code to match based on a matching PROD_GROUP.&amp;nbsp; A separate, similar set of steps would be needed if the first pass produces no match.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, create the format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=historic out=historic_sorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by member_ID prod_group;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data ranges;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set historic_sorted end=done;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by member_ID prod_group;&lt;/P&gt;&lt;P&gt;&amp;nbsp; fmtname = '$ranges';&lt;/P&gt;&lt;P&gt;&amp;nbsp; length label $ 8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; label = put(_n_-1, 5.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain start;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.prod_group then start = member_id || ' ' || put(prod_group, z2.) || ' ' || put(service_date, yymmdd10.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end = &lt;SPAN style="font-size: 13.3333330154419px;"&gt;member_id || ' ' || put(prod_group, z2.) || ' ' || put(service_date-1, yymmdd10.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; start = &lt;SPAN style="font-size: 13.3333330154419px;"&gt;member_id || ' ' || put(prod_group, z2.) || ' ' || put(service_date, yymmdd10.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.prod_group then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end = &lt;SPAN style="font-size: 13.3333330154419px;"&gt;member_id || ' ' || put(prod_group, z2.) || ' ' || put(service_date+364, yymmdd10.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if done then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hlo='O';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label='No Match';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc format cntlin=ranges;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That creates the format, although I probably need to look at this with fresh eyes in the morning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use the format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set transaction;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i_=service_date to service_date-364 by -1 until (search_result ne 'No Match');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; search_result = put(&lt;SPAN style="font-size: 13.3333330154419px;"&gt;member_id || ' ' || put(prod_group, z2.) || ' ' || put(_i_, yymmdd10.), $ranges.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if search_result ne 'No Match' then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; matching_record = input(search_result, 5.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set historic_sorted point=matching_record;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Add code to set all variables from historic data to missing;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it's hard enough as is, and would need another batch of similar code to perform a follow-up search if no match was found the first time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 03:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202401#M37746</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-03-17T03:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202402#M37747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You'd better post these two tables and the output you need .Don't forget to write some words to explain your question clearly .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 08:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202402#M37747</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-03-17T08:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202403#M37748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;First sort datasets by Member_ID and Service_Date.&lt;/P&gt;&lt;P&gt;The read them with a set/by statement (interleaving).&lt;/P&gt;&lt;P&gt;When reading from the history dataset, store the needed variables in a hash object. Key will be the Prod_Group.&amp;nbsp; If key already exist, just replace, since the dataset is sorted by time, and you need only&amp;nbsp; the latest.&lt;/P&gt;&lt;P&gt;Also store the needed variables globally (not per group). For simplicity, my code stores it in the same hash object, with key=0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When reading from qualified dataset, retrieve the needed values from the hash object. Of course, first try with key=Prod_Group. If no success, or entry is too old, try with key=0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All this should be done for each Memeber_ID. I am simply clearing the hash object at the beginning of&amp;nbsp; a new group(Member_ID).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please test it with more meaningful data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data qualified;&lt;/P&gt;&lt;P&gt;input Member_ID Transaction_ID Service_Date:yymmdd10. Prod_Group;&lt;/P&gt;&lt;P&gt;format Service_Date yymmdd10. ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 123 2014-01-05 1&lt;/P&gt;&lt;P&gt;1 124 2014-01-08 3&lt;/P&gt;&lt;P&gt;2 126 2014-01-07 2&lt;/P&gt;&lt;P&gt;3 128 2014-01-26 5&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data history;&lt;/P&gt;&lt;P&gt;input Member_ID Transaction_ID Service_Date:yymmdd10. Prod_Group Product_ID;&lt;/P&gt;&lt;P&gt;format Service_Date yymmdd10. ;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 123 2013-02-05 1 3&lt;/P&gt;&lt;P&gt;1 124 2013-05-08 3 4&lt;/P&gt;&lt;P&gt;2 126 2013-07-07 2 6&lt;/P&gt;&lt;P&gt;3 128 2014-01-26 5 6&lt;/P&gt;&lt;P&gt;1 123 2013-01-05 1 7&lt;/P&gt;&lt;P&gt;1 124 2013-01-08 3 8&lt;/P&gt;&lt;P&gt;2 126 2014-01-07 2 8&lt;/P&gt;&lt;P&gt;3 128 2014-01-26 5 8&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/*Sort by ID and date*/&lt;/P&gt;&lt;P&gt;proc sort data=qualified;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Member_ID Service_Date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=history;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Member_ID Service_Date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;if _n_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dcl hash lastGroup();&lt;/P&gt;&lt;P&gt;&amp;nbsp; lastGroup.defineKey('H_Prod_Group');&lt;/P&gt;&lt;P&gt;&amp;nbsp; lastGroup.defineData('H_Transaction_ID');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lastGroup.defineData('H_Service_Date');&lt;/P&gt;&lt;P&gt;&amp;nbsp; lastGroup.defineData('H_Prod_Group');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lastGroup.defineData('H_Product_ID');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lastGroup.defineDone();&lt;/P&gt;&lt;P&gt;&amp;nbsp; /*The following line is just a trick to define H_: variables in the PDV*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set history(rename=(Transaction_ID=H_Transaction_ID Service_Date=H_Service_Date Prod_Group=H_Prod_Group Product_ID=H_Product_ID));&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set qualified(in=inQ) history(in=inH);&lt;/P&gt;&lt;P&gt;by Member_ID Service_Date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if first.Member_ID then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lastGroup.clear();&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if inH then do;/*Storing data about the last transaction per group, and also globally (key:0)*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.add&amp;nbsp;&amp;nbsp;&amp;nbsp; (key:Prod_Group,data:Transaction_ID,data:Service_Date,data:Prod_Group,data:Product_ID);&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.replace(key:Prod_Group,data:Transaction_ID,data:Service_Date,data:Prod_Group,data:Product_ID);&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.add&amp;nbsp;&amp;nbsp;&amp;nbsp; (key:0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,data:Transaction_ID,data:Service_Date,data:Prod_Group,data:Product_ID);&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.replace(key:0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,data:Transaction_ID,data:Service_Date,data:Prod_Group,data:Product_ID);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if inQ then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.find(key:Prod_Group);/*fetch group specific*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; putlog rc=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if rc~=0 or H_Service_Date&amp;lt;=intnx('day',Service_Date,-365,'s') then do;/*not found or old entry*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing(of H_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.find(key:0);/*fetch global*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; if rc~=0 or H_Service_Date&amp;lt;=intnx('day',Service_Date,-365,'s') then do;/*not found or old entry*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing(of H_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 11:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202403#M37748</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-03-17T11:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202404#M37749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;wow thank you.&lt;/P&gt;&lt;P&gt;I don't fully understand it yet, but it worked!&lt;/P&gt;&lt;P&gt;Do you have any links you can direct me to for a deeper understanding of hash objects?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:16:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202404#M37749</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-17T12:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202405#M37750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gergely,&lt;/P&gt;&lt;P&gt;your solution will give me the the match on Prod_Group, where would you suggest I adjust the code to take into account transactions where there is no previous transactions within the Same product group and pull the latest transaction from ANY product group?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202405#M37750</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-17T12:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202406#M37751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The code is supposed to do it. To test it, change the last line of history dataset to:&lt;/P&gt;&lt;P&gt;3 128 &lt;STRONG&gt;2013-05-26&lt;/STRONG&gt; &lt;STRONG&gt;4&lt;/STRONG&gt; 8&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(If date in history is the same as date in qualified, then this data step ignores it! Because it is not "history" - it happened on the same day.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202406#M37751</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-03-17T12:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202407#M37752</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the SAS doc about hash objects is a good starting point:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n1b4cbtmb049xtn1vh9x4waiioz4.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n1b4cbtmb049xtn1vh9x4waiioz4.htm"&gt;SAS(R) 9.3 Language Reference: Concepts, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 12:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202407#M37752</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-03-17T12:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202408#M37753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah I see, logically, I agree with you, although the business rules says otherwise :smileysilly:&lt;/P&gt;&lt;P&gt;I imagine it is in this block the logic will change to include the same day transactions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if inQ then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.find(key:Prod_Group);/*fetch group specific*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; putlog rc=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if rc~=0 or H_Service_Date&amp;lt;=intnx('day',Service_Date,-&amp;amp;LB_Period_Days,'s') then do;/*not found or old entry*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing(of H_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; rc=lastGroup.find(key:0);/*fetch global*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; if rc~=0 or H_Service_Date&amp;lt;=intnx('day',Service_Date,-&amp;amp;LB_Period_Days,'s') then do;/*not found or old entry*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; call missing(of H_:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 13:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202408#M37753</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-17T13:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202409#M37754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Almost &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;The logic that handles "group found" and "group not found" is there.&lt;/P&gt;&lt;P&gt;But in this case what happens to such contemporary pairs is determined by the order the data step reads them.&lt;/P&gt;&lt;P&gt;So in this case you have to make changes here:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; background-color: #ffffff; text-decoration: line-through; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;set qualified(in=inQ) history(in=inH);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;set &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;history(in=inH) &lt;/SPAN&gt;qualified(in=inQ);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Do you also need to take into account observation in the history data set, that are later then the current qualified?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 13:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202409#M37754</guid>
      <dc:creator>gergely_batho</dc:creator>
      <dc:date>2015-03-17T13:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202410#M37755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;No, the qualify dataset is a subset of the History table for the latest month (in this case Jan). There will never be records into the future.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are many cases where a member will have a transaction across multiple product groups in the same day. When I made the change you suggested, it may pull the exact same transaction that is being evaluated, so the hash variables are equivalent to the qualified transaction.&lt;/P&gt;&lt;P&gt;Is there away to 'skip' that transaction and look for the other transaction in the different product group?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 15:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202410#M37755</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-17T15:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202411#M37756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;A proposed solution, array-based. &lt;/SPAN&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;First, building 2 simulated datasets with shorter variable names:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; Member_ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; mbr_id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; Transaction_ID&amp;nbsp; -&amp;gt; trs_id&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; Service_Date&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; srv_dt&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; Prod_Group&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;gt; prd_gp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;Second, the proposed solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;I assume that all mbr_id in the qualified table are present in the history table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;/*****************************************************************/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;/*** simulated datasets for qualified (t_a) and historic (t_b) ***/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;/*****************************************************************/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;data t_a(keep=mbr_id srv_dt trs_id prd_gp rnd)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t_b(keep=mbr_id srv_dt trs_id prd_gp rnd);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; do mbr_id = 1 to 10;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trs_id = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; srv_dt=15000;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do zR = 1 to 200;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rnd=ceil(60*ranuni(3));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; srv_dt+rnd;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; trs_id+ceil(6*ranuni(3));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prd_gp = ceil(10*ranuni(3));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if zR in (197,198,199,200) then do;&amp;nbsp; output t_a; output t_b; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else output t_b;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; format srv_dt date9.;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;/*****************************/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;/*** solution using arrays ***/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;/*****************************/&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;proc sort data=t_a; by mbr_id descending srv_dt; run; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;proc sort data=t_b; by mbr_id descending srv_dt; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; select max(cnts) into :cQual&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp; (select mbr_id, sum(1) as cnts from t_a group by mbr_id);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; select max(cnts) into :cHist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp; (select mbr_id, sum(1) as cnts from t_b group by mbr_id);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;data t_c(keep=mbr_id aSrv_dt aPrd_gp aTrs_id bSrv_dt bPrd_gp bTrs_id dday&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rename=(aSrv_dt=srv_dt aPrd_gp=prd_gp aTrs_id=trs_id));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; array R1(&amp;amp;cQual); * qualified, srv_dt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; array R2(&amp;amp;cQual); * qualified, prd_gp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; array R3(&amp;amp;cQual); * qualified, trs_id;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; array S1(&amp;amp;cHist); * history,&amp;nbsp;&amp;nbsp; srv_dt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; array S2(&amp;amp;cHist); * history,&amp;nbsp;&amp;nbsp; prd_gp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; array S3(&amp;amp;cHist); * history,&amp;nbsp;&amp;nbsp; trs_id;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; aCnt=0; bCnt=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; do until (last.mbr_id);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set t_a;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by mbr_id;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aCnt+1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R1(aCnt)=srv_dt; R2(aCnt)=prd_gp; R3(aCnt)=trs_id;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; do until (last.mbr_id);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set t_b;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by mbr_id;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bCnt+1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; S1(bCnt)=srv_dt; S2(bCnt)=prd_gp; S3(bCnt)=trs_id;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; do i = 1 to aCnt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zMatch=0; zOther=0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aSrv_dt=R1(i); aPrd_gp=R2(i); aTrs_id=R3(i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do j = 1 to bCnt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (R2(i)=S2(j)) and (0&amp;lt; R1(i)-S1(j)&amp;lt;= 365) then do;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zMatch=max(zMatch,1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bSrv_dt=S1(j); bPrd_gp=S2(j); bTrs_id=S3(j); dday=R1(i)-S1(j);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not(R2(i)=S2(j)) and (0&amp;lt;=R1(i)-S1(j)&amp;lt;= 365) and (zOther=0) then do;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zOther=max(zOther,1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cSrv_dt=S1(j); cPrd_gp=S2(j); cTrs_id=S3(j); eday=R1(i)-S1(j);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (zMatch=0) and (zOther=1) then do;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bSrv_dt=cSrv_dt; bPrd_gp=cPrd_gp; bTrs_id=cTrs_id; dday=eday;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (zMatch=0) and (zOther=0) then do;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bSrv_dt=aSrv_dt; bPrd_gp=aPrd_gp; bTrs_id=aTrs_id; dday=0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp; end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format aSrv_dt bSrv_dt date9.;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;For mbr_id = 1 one gets:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;mbr_id&amp;nbsp; srv_dt&amp;nbsp; prd_gp&amp;nbsp; trs_id&amp;nbsp; bSrv_dt&amp;nbsp;&amp;nbsp; bPrd_gp&amp;nbsp; bTrs_id&amp;nbsp; dday&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20-Dec-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 737&amp;nbsp;&amp;nbsp; 14-Dec-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 736&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20-Dec-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 737&amp;nbsp;&amp;nbsp; 27-Aug-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 730&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 115&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20-Dec-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 737&amp;nbsp;&amp;nbsp; 17-May-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 721&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 217&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20-Dec-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 737&amp;nbsp;&amp;nbsp;&amp;nbsp; 1-Mar-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 713&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 294&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14-Dec-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 736&amp;nbsp;&amp;nbsp; 27-Aug-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 730&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 109&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14-Dec-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 736&amp;nbsp;&amp;nbsp; 17-May-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 721&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 211&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14-Dec-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 736&amp;nbsp;&amp;nbsp;&amp;nbsp; 1-Mar-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 713&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 288&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 25-Oct-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp; 735&amp;nbsp;&amp;nbsp; 27-Aug-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 730&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 59&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27-Aug-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 730&amp;nbsp;&amp;nbsp; 17-May-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 721&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 102&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27-Aug-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp; 730&amp;nbsp;&amp;nbsp;&amp;nbsp; 1-Mar-17&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 713&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 179&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt;for (srv_dt=25-Oct-17; prd_gp=8) there are no other transactions for mbr_id=1 and prd_gp=8 which is within 365 days, thus the entry for prd_gp=9.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 23:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202411#M37756</guid>
      <dc:creator>billfish</dc:creator>
      <dc:date>2015-03-17T23:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic ranges and lookup logic</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202412#M37757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. This is a great approach I will look into it with&amp;nbsp; more detail.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Mar 2015 13:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-ranges-and-lookup-logic/m-p/202412#M37757</guid>
      <dc:creator>DangIT</dc:creator>
      <dc:date>2015-03-19T13:00:59Z</dc:date>
    </item>
  </channel>
</rss>

