Dear friends, I would like to create the "combo2 and old" at the highlight below based on the conditions, and comparing the variables at end of the condition or 1st record dose not apply the condition. I am wondering what is wrong with the "do while" statement. Thank you very much! data t; input dt date9. name $ ; format dt mmddyy10.; datalines; 09SEP2015 a 29SEP2015 b 30SEP2015 a 06OCT2015 b 02NOV2015 c 16NOV2015 a 23NOV2015 c 30NOV2015 a ; run; data t1; set t; format dt1 mmddyy10. ; retain dt1 combo1 combo2; length combo1 combo2 $20. ; if name = 'c' and dt ='02NOV2015'd then do; combo1 = 'a+b'; combo2 = 'c'; dt1 = dt; end; else do; do while (.< dt1 < dt < dt1 + 20); if findw(combo2, strip(name)) = 0 then combo2 = cats(combo2,"+", strip(name)); end; do i = 1 to countc(combo1, "+") + 1 ; if findw(combo2, strip(scan(combo1, i, "+"))) > 0 then old = 1; else old = 0; end; end; run; dt name Combo1 combo2 old Dt1 9/9/2015 a 9/29/2015 b 9/30/2015 a 10/6/2015 b a+b 11/2/2015 c 11/2/2015 11/16/2015 a c+a 1 11/2/2015 11/23/2015 c 11/2/2015 11/30/2015 a 11/2/2015
... View more