Please mark the question as answered and award the correct answers to extraordinary master Xia Keshan. I tried to play around with your requirement, but unfortunately couldn;t meet it properly. But for learning purpose, you can play and have fun data have; input Group $ dollar time24hrs : time.; *format time24hrs time.; cards; a 10 2:43 a 10 8:34 a 11 11:52 b 16 5:32 b 18 7:16 b 12 14:08 b 11 20:34 b 13 21:31 c 11 2:18 c 12 8:34 d 18 14:12 e 19 2:43 e 17 5:30 e 11 12:07 e 14 20:40 e 16 20:46 f 11 8:24 f 12 11:55 ; run; data want new(keep=group remarks); set have; by group; k=lag(time24hrs); if first.group then do; totaldollar=0; grpcount=0; sumtimediff=0; end; grpcount+1; totaldollar+dollar; if not first.group then do; deltatime=intck('hour',k,time24hrs); sumtimediff+deltatime; end; if grpcount>=2 and totaldollar>=25 and sumtimediff le 3 then do; remarks='yes'; output new; end; output want; run; data final; merge want new; by group; keep group dollar time24hrs remarks; run;
... View more