- *simulate bond trading data;
- data bond;
- format date mmddyy10.;
- do code=1 to 5;
- do date=20000 to 20200 by 2;
- output;
- end;
- end;
-
- do code=6 to 10;
- do date=20000 to 20200;
- output;
- end;
- end;
- run;
- *generate trading date calendar;
- proc sql;
- create table trading_date as
- select distinct date from bond
- order by date;
- quit;
-
- data trading_date;
- set trading_date;
- index+1;
- run;
-
- *reindex bond data by trading date;
- proc sql;
- create table bond2 as
- select b.index, a.* from bond a right join trading_date b
- on a.date = b.date
- order by code, date;
- quit;
- * count continuous trading date;
- data bond3;
- set bond2;
- by code;
- retain continuous_sign 0;
- if index=lag(index)+1 then continuous_count+1;
- else continuous_count=1;
- if first.code then continuous_count=0;
- run;
-
- proc sql;
- create table bond4 as
- select code, max(continuous_count) as max_count from bond3
- group by code
- having max(continuous_count)<10;
- quit;
-
-


雷达卡





京公网安备 11010802022788号







