The HASH object allows you to create a dynamic array indexed on CUSTID and accumulate the counts. data email; infile datalines eof=eof; input custid $ date MMDDYY8. response $; length count 8; if _n_ eq 1 then do; declare hash h(ordered:'Y'); h.definekey('custid'); h.definedata('custid','count'); h.definedone(); end; call missing(count); rc=h.find(); count + 1; rc=h.replace(); return; eof: h.output(dataset:'count'); stop; format date MMDDYY10.; drop count rc; datalines; A 12-22-10 Y B 09-18-07 N C 08-11-11 Y A 03-19-03 Y B 09-01-01 N C 08-03-12 N D 03-01-04 Y A 11-08-08 Y B 03-09-09 Y C 09-06-09 Y E 09-08-09 Y A 09-09-09 Y C 09-06-09 Y B 09-01-06 N E 09-03-12 Y D 09-23-11 Y A 01-01-00 Y C 09-08-02 Y D 09-07-00 Y F 09-09-09 Y B 09-01-00 N C 01-01-00 N ; run;
... View more