- proc sql noprint;
- create table a0 as
- select distinct code
- , qdate
- from a
- order by code, qdate
- ;
- quit;
- data a1;
- set a0;
- by code;
- if first.code then _day=0;
- _day+1;
- run;
- proc sql noprint;
- create table final as
- select code
- , qdate
- , qtime
- , price
- from (
- /* if table is too large, use date step with hash */
- select a.*
- , bb.code as expcode
- from a left join
- (
- /*create 7 day window for each stock*/
- select a1.code, a1.qdate
- from a1 inner join (
- /* attach op-day index to exdate */
- select c.code, c.exdt, a1._day
- from c left join a1 on c.code=a1.code)bb
- on a1.code=bb.code
- and abs(a._day-bb._day) le 3
- )bb
- on a.code=bb.code
- and a.qdate=bb.qdate
- )
- where expcode is missing
- ;


雷达卡



京公网安备 11010802022788号







