Maybe this will be my last question. I'm really appreciate all your help. According to your answers, I think the hash code follow this process. if first.id then h.clear(); : In the first row of id, the 'definedata' get cleared. So, 'clinic', 'count', 'countsquare' value in hash object will be deleted. if h.find() = 0 : I think when the hash code run first time, it read the first row of definekey. For example, "Brad" get injured and he went to clinic "A". So, in "Brad" medical utilization data, the first row of clinic is "A". Hash code import "A" in clinic data. After, hash code finds "A" in "have" dataset, and it returns 0. then do;
count = count + 1;
countsquare = count ** 2;
h.replace();
end; : If "Brad" visited clinic "A" continuously, "h.find" return 0 iteratively. So "count+1 and count**2" process run iteratively. else do;
count = 1;
countsquare = 1;
h.replace(); : This mean SAS finds the new value of definekey, 'clinic'. For example, Brad had visited the clinic "A", but he went new clinic "B". This situation means 'else' (skipped) do while (hi.next() = 0);
if _clinic ne clinic then sum + countsquare; hi.next()=0 means, If Brad visited clinics like this, clinic : A -> A -> A -> B -> B -> B -> ... next : 0 -> 0 -> not zero -> 0 -> 0 -> 0 ....
... View more