Got some time to work on a data step solution, which will be benificial if you have a huge data set. so fwiw, here it is:
data want;
set have;
by site;
array _dt(0:89) _temporary_;
array _ct(0:89) _temporary_;
array _sum(0:89) _temporary_;
if first.site then
call missing (of _dt(*), of _ct(*), of _sum(*));
_dt(mod(_n_,90))=date_pm;
_ct(mod(_n_,90))=concn;
_sum(mod(_n_,90))=concsum;
_range=range(of _dt(*));
do while (_range>90);
_beg=whichn(min(of _dt(*)),of _dt(*))-1;
call missing(_dt(_beg), _ct(_beg), _sum(_beg));
_range=range(of _dt(*));
end;
avg=sum(of _sum(*))/sum(of _ct(*));
if max(of _dt(*))-min(of _dt(*)) < 90 then
call missing(AVG);
drop _:;
run;
Hash object can also do the same.
... View more