There are several ways to obtain the closing price on the first trading day. This is probably the simplest:
data close_price;
set crsp.dsf (keep=permno date prc);
where missing(prc)=0 ;
by permno date; *Using DSF sort order;
if first.permno=1; *Selects the first valid case for PERMNO;
prc=abs(prc);
run;
Alternatively, you can use the CRSP.STOCKNAMES file, where variable ST_DATE (starting date of price data) is available for every permno and then extract the relevant price information from CRSP daily file CRSP.DSF.
Finally, the CRSP company name file CRSP.DSFHDR can also be used to obtain the first date of price data (recorded in BEGPRC) variable.
For the last method, the code to produce the first-day price is as follows:
proc
sql ;
create table close_prc
as select
b.date, b.permno, abs(b.prc) as prc
from
crsp.dsfhdr as a (keep=permno begprc)
left join
crsp.dsf as b (keep=permno date prc)
on a.permno=b.permno and a.begprc=b.date
order by a.permno;
quit ;
Comments
0 comments
Please sign in to leave a comment.