Well, if I understand you correctly, you are trying to mark improvement percent base on 30 days interval. Here is one approach you could meddle around to suit your need: data have; do id=1 to 10; do date=1 to 365; mark=ceil(ranuni(0)*100); output; end; end; run; data want; array t(0:30) _temporary_; do _n_=1 by 1 until (last.id); set have; by id; t(mod(_n_,31))=mark; if _n_>=31 then pct=(t(mod(_n_,31))-t(mod((_n_-30),31)))/t(mod((_n_-30),31)); output; end; run; Haikuo
... View more