GoogleSearch
이 블로그 검색
SDC platunum data format (text dump)
라벨:
Informatics
이메일로 전송BlogThis!X에 공유Facebook에서 공유
%LET dirSDC = P:\research\sas_projects\wrds_libs_sas_scripts\sdc platinum;
filename SDC1 "&dirSDC;\ma 1975 - 1979.txt";filename SDC2 "&dirSDC;\ma 1998 - 1999.txt";filename SDC3 "&dirSDC;\ma 2000 - 2010.txt";data work.a_sdc1;infile SDC1 dsd DELIMITER="" firstobs=8 LRECL=32767 missover;input annDate_temp $ 1-8 effDate_temp $ 14-21 targetName $ 27-59 acqName $ 63-98 pctShare 99-104 acqCusip $ 109-114 acqCusip2 $ 120-125 tgtCusip $ 131-136 ;run;data work.a_sdc2;infile SDC2 dsd DELIMITER="" firstobs=8 LRECL=32767 missover;input annDate_temp $ 1-8 effDate_temp $ 14-21 targetName $ 27-69 acqName $ 71-111 pctShare 113-118 acqCusip $ 123-128 acqCusip2 $ 135-140 tgtCusip $ 147-152 ;run;
data work.a_sdc3;infile SDC3 dsd DELIMITER="" firstobs=8 LRECL=32767 missover;input annDate_temp $ 1-8 effDate_temp $ 14-21 targetName $ 27-66 acqName $ 67-104 pctShare 105-110 acqCusip $ 115-120 acqCusip2 $ 127-132 tgtCusip $ 139-144 ;run;data work.a_sdc4 (drop = year month day annDate_temp effDate_temp);set work.a_sdc1 work.a_sdc2 work.a_sdc3;year = substr(annDate_temp, 7, 2);month = substr(annDate_temp, 1, 2);day = substr(annDate_temp, 4, 2);annDate = mdy(month, day, year);format annDate date9.;year = substr(effDate_temp, 7, 2);month = substr(effDate_temp, 1, 2);day = substr(effDate_temp, 4, 2);effDate = mdy(month, day, year);format effDate date9.;
if annDate ne .;
if pctShare eq 100;sdcFlag = 1;run;proc sort data=work.a_sdc4; by tgtCusip annDate;run;/* Get crsp.dsenames */data work.a_sdc5 (keep = permno NAMEDT NAMEENDT ncusip cusip cusip6 ncusip6);set crsp.dsenames;cusip6 = substr(cusip, 1, 6);ncusip6 = substr(ncusip, 1, 6);run;/* Add cusip */proc sql;
create table work.a_sdc6 as
select
a.*,
b.permno as acqpermno_1
from
work.a_sdc4 a
LEFT JOIN
work.a_sdc5 b
ON
a.acqCusip = b.ncusip6
and b.NAMEDT <= a.annDate <= b.NAMEENDT;quit;proc sql;
create table work.a_sdc7 as
select
a.*,
b.permno as acqpermno_2
from
work.a_sdc6 a
LEFT JOIN
work.a_sdc5 b
ON
a.acqCusip2 = b.ncusip6
and b.NAMEDT <= a.annDate <= b.NAMEENDT;quit;
data work.a_sdc8 (keep = targetName acqName acqCusip acqCusip2 tgtCusip annDate effDate acqPermno);set work.a_sdc7;acqPermno = acqpermno_1;
if acqPermno eq . then acqPermno = acqpermno_2;run;
/* Add gvkey */proc sql;
create table work.a_sdc9 as
select a.*, b.gvkey as acqGvkey
from
work.a_sdc8 a
LEFT JOIN
matching.ccm b
ON
a.acqPermno = b.lpermno
and b.USEDFLAG = 1
and b.LINKDT <= a.annDate <= b.LINKENDDT
and b.linkprim IN ("C", "P");quit;
/* Add cusip target*/proc sql;
create table work.a_sdc10 as
select
a.*,
b.permno as tgtPermno
from
work.a_sdc9 a
LEFT JOIN
work.a_sdc5 b
ON
a.tgtCusip = b.ncusip6
and b.NAMEDT <= a.annDate <= b.NAMEENDT;quit;
/* Add target gvkey */proc sql;
create table misc.sdc as
select a.*, b.gvkey as tgtGvkey
from
work.a_sdc10 a
LEFT JOIN
matching.ccm b
ON
a.tgtPermno = b.lpermno
and b.USEDFLAG = 1
and b.LINKDT <= a.annDate <= b.LINKENDDT
and b.linkprim IN ("C", "P");quit;
proc sort data = misc.sdc; by annDate; run;
이메일로 전송BlogThis!X에 공유Facebook에서 공유
라벨:
Informatics
%LET dirSDC = P:\research\sas_projects\wrds_libs_sas_scripts\sdc platinum;
filename SDC1 "&dirSDC;\ma 1975 - 1979.txt";filename SDC2 "&dirSDC;\ma 1998 - 1999.txt";filename SDC3 "&dirSDC;\ma 2000 - 2010.txt";data work.a_sdc1;infile SDC1 dsd DELIMITER="" firstobs=8 LRECL=32767 missover;input annDate_temp $ 1-8 effDate_temp $ 14-21 targetName $ 27-59 acqName $ 63-98 pctShare 99-104 acqCusip $ 109-114 acqCusip2 $ 120-125 tgtCusip $ 131-136 ;run;data work.a_sdc2;infile SDC2 dsd DELIMITER="" firstobs=8 LRECL=32767 missover;input annDate_temp $ 1-8 effDate_temp $ 14-21 targetName $ 27-69 acqName $ 71-111 pctShare 113-118 acqCusip $ 123-128 acqCusip2 $ 135-140 tgtCusip $ 147-152 ;run;
data work.a_sdc3;infile SDC3 dsd DELIMITER="" firstobs=8 LRECL=32767 missover;input annDate_temp $ 1-8 effDate_temp $ 14-21 targetName $ 27-66 acqName $ 67-104 pctShare 105-110 acqCusip $ 115-120 acqCusip2 $ 127-132 tgtCusip $ 139-144 ;run;data work.a_sdc4 (drop = year month day annDate_temp effDate_temp);set work.a_sdc1 work.a_sdc2 work.a_sdc3;year = substr(annDate_temp, 7, 2);month = substr(annDate_temp, 1, 2);day = substr(annDate_temp, 4, 2);annDate = mdy(month, day, year);format annDate date9.;year = substr(effDate_temp, 7, 2);month = substr(effDate_temp, 1, 2);day = substr(effDate_temp, 4, 2);effDate = mdy(month, day, year);format effDate date9.;
if annDate ne .;
if pctShare eq 100;sdcFlag = 1;run;proc sort data=work.a_sdc4; by tgtCusip annDate;run;/* Get crsp.dsenames */data work.a_sdc5 (keep = permno NAMEDT NAMEENDT ncusip cusip cusip6 ncusip6);set crsp.dsenames;cusip6 = substr(cusip, 1, 6);ncusip6 = substr(ncusip, 1, 6);run;/* Add cusip */proc sql;
create table work.a_sdc6 as
select
a.*,
b.permno as acqpermno_1
from
work.a_sdc4 a
LEFT JOIN
work.a_sdc5 b
ON
a.acqCusip = b.ncusip6
and b.NAMEDT <= a.annDate <= b.NAMEENDT;quit;proc sql;
create table work.a_sdc7 as
select
a.*,
b.permno as acqpermno_2
from
work.a_sdc6 a
LEFT JOIN
work.a_sdc5 b
ON
a.acqCusip2 = b.ncusip6
and b.NAMEDT <= a.annDate <= b.NAMEENDT;quit;
data work.a_sdc8 (keep = targetName acqName acqCusip acqCusip2 tgtCusip annDate effDate acqPermno);set work.a_sdc7;acqPermno = acqpermno_1;
if acqPermno eq . then acqPermno = acqpermno_2;run;
/* Add gvkey */proc sql;
create table work.a_sdc9 as
select a.*, b.gvkey as acqGvkey
from
work.a_sdc8 a
LEFT JOIN
matching.ccm b
ON
a.acqPermno = b.lpermno
and b.USEDFLAG = 1
and b.LINKDT <= a.annDate <= b.LINKENDDT
and b.linkprim IN ("C", "P");quit;
/* Add cusip target*/proc sql;
create table work.a_sdc10 as
select
a.*,
b.permno as tgtPermno
from
work.a_sdc9 a
LEFT JOIN
work.a_sdc5 b
ON
a.tgtCusip = b.ncusip6
and b.NAMEDT <= a.annDate <= b.NAMEENDT;quit;
/* Add target gvkey */proc sql;
create table misc.sdc as
select a.*, b.gvkey as tgtGvkey
from
work.a_sdc10 a
LEFT JOIN
matching.ccm b
ON
a.tgtPermno = b.lpermno
and b.USEDFLAG = 1
and b.LINKDT <= a.annDate <= b.LINKENDDT
and b.linkprim IN ("C", "P");quit;
proc sort data = misc.sdc; by annDate; run;
Scientist. Husband. Daddy. --- TOLLE. LEGE
외부자료의 인용에 있어 대한민국 저작권법(28조)과 U.S. Copyright Act (17 USC. §107)에 정의된 "저작권물의 공정한 이용원칙 | the U.S. fair use doctrine" 을 따릅니다. 저작권(© 최광민)이 명시된 모든 글과 번역문들에 대해 (1) 복제-배포, (2) 임의수정 및 자의적 본문 발췌, (3) 무단배포를 위한 화면캡처를 금하며, (4) 인용 시 URL 주소 만을 사용할 수 있습니다. [후원 | 운영] [대문으로] [방명록] [옛 방명록] [티스토리 (백업)] [신시내티]
-