/* File name: /home/nwu/pledesma/extract.sas */


data out.mse;
set crsp.mse;
where ticker in ("DELL" "F" "HWP" "ENE" "COKE"
                 "CTAS" "PH" "CAT" "LMT" "GWW"
                 "ITT" "ADP" "FDX" "EMR" "UNP",
                 "AVY" "DHR","PCAR","UTX" "ITW",
                 "ETN" "FDC" "GD" "NOC" "MMM");

proc sort data=out.mse nodupkey;
by permno;

proc print data=out.mse;

proc contents data=out.mse;

data out.msfnames;
merge crsp.msfnames out.mse (in=a);
by permno;
if a;

proc print data=out.msfnames;
proc contents data=out.msfnames;

data out.msf;
merge crsp.msf out.mse (in=a);
by permno;
if a;
if year(date) ge 1996;

proc print data=out.msf (obs=20);

proc contents data=out.msf;

data out.msi;
set crsp.msi (keep=date vwretd sprtrn);
where year(date) ge 1996;

proc print data=out.msi (obs=20);

proc contents data=out.msi;

data out.riskfree;
set crsp.riskfree (keep=qdate ave_1 ask_1 bid_1 crspid_1 dur_1);
where year(qdate) ge 1996;

proc print data=out.riskfree;
proc contents data=out.riskfree;


data out.cstqtr;
merge crsp.cstqtr (keep=permno gvkey date dnum data1 data2
                   data10 data20 data30 data44 data50 data51)
      out.mse (in=a);
by permno;
if a;
if year(date) ge 1996;

proc print data=out.cstqtr (obs=20);
proc contents data=out.cstqtr (obs=20);