Use double set with key lookup to account for missing dates, similar to my previous method using double set statements and point: data foo(index=(date /nomiss /unique)); call streaminit(12345); do date='01JAN1960'd to today(); count=int(rand('uniform')*10e2); if rand('table',.95)=1 then output; end; format date date9.; run; data bar; set foo(rename=(date=_date)) nobs=nobs; sum=.; miss=0; do date=_date-10 by 1 while ( date < _date and _n_ > 10 /* and miss=0 */ ); set foo key=date/unique; if _iorc_ then do; _iorc_=0; _error_=0; miss+1; end; else do; sum+count; end; end; *if miss>1 then call missing(sum); date=_date; drop _date; run;
... View more