- proc sql noprint;
- create table final as
- select b.firmid
- , b.fyear
- , ifn(c.out>0, 1, 0) as turnover
- from (select distinct firmid, fyear from sample1 order by firmid, fyear) b left join (
- /*count the number of resigned employee*/
- select firmid
- , fyear
- , count(directorid) as out
- from (
- /*exclude retained employee*/
- select aa.firmid
- , aa.fyear
- , aa.directorid
- , bb.directorid as tmp
- from sample1 aa left join (
- /*retained employee */
- select a.firmid
- , b.fyear
- , a.directorid
- from sample1 a, sample1 b
- where a.firmid = b.firmid
- and a.directorid = b.directorid
- and a.fyear +1 = b.fyear
- )bb
- on aa.firmid=bb.firmid
- and aa.fyear=bb.fyear
- and aa.directorid=bb.directorid
- )
- where tmp is missing
- group by firmid, fyear
- )c
- on b.firmid=c.firmid
- and b.fyear=c.fyear
- ;


雷达卡

京公网安备 11010802022788号







