Hi all, I hope you all have a good weekend! I am using the following code to compute statistics that I need: data want; if _N_ = 1 then do; dcl hash h(multidata : "Y", ordered : "Y"); h.definekey("d", "t"); h.definedata("d", "t", "v", "p"); h.definedone(); dcl hiter hi("h"); dcl hash hh(); hh.definekey("d", "t"); hh.definedata("s"); hh.definedone(); do until (z); set have end = z; h.add(key : date, key : time, data : date, data : time, data : volume, data : price); if hh.find(key : date, key : Time) ne 0 then s = volume; else s + volume;* will be used to compute vol-weig price ; hh.replace(key : date, key : Time, data : s); end; end; set have; d = .; t = .; v = .; p = .; s = .; if h.find(key : Date, key : Time + 10) = 0 then mt = t; else do; rc = hi.setcur(key : Date, key : Time); do i = 1 by 1 while(hi.next() = 0 & Date = d); if t - time > 10 then do; if i = 1 then mt = .; leave; end; if t > time then mt = t; end; end; rc = hh.find(key: date, key : mt); rc = h.reset_dup(); do while (h.do_over(key : date, key : mt) = 0); pp = sum(pp, divide(v, s) * p); end; dif = (log(price) - log(pp))*10000; *bps; run; The issue is I need to apply this function by group. Is there an easy way of doing this? Thanks!
... View more