I am calculating the number of firms from 2000 to 2013. I was wondering about following code. If i will keep the following varaiables, i will have no permno,then how can i sort by permno? sorry for being greedy but if anyone can share with me complete code of crsp_m, i would really appreciate guys. thanks a lot. (PS: I do not directly download from wrds, i have the data sets in my laptop)
/* Create a CRSP Subsample with Monthly Stock and Event Variables */
/* This procedure creates a SAS dataset named "CRSP_M" */
/* Restrictions will be applied later */
/* Select variables from the CRSP monthly stock and event datasets */
%let msevars=ticker ncusip shrcd exchcd;
%let msfvars = prc ret retx shrout cfacpr cfacshr;
%include '/wrds/crsp/samples/crspmerge.sas' ;
%crspmerge(s=m,start=01jan1959,end=31dec2009,sfvars=&msfvars,sevars=&msevars,filters=exchcd in (1,2,3));
/* CRSP_M is sorted by date and permno) and has historical returns */
/* as well as historical share codes and exchange codes */
/* Add CRSP delisting returns */
proc sql;
create table crsp_m2
as select a.*, b.dlret,
sum(1,ret)*sum(1,dlret)-1 as retadj "adjusted return for delisting",
abs(a.prc*a.shrout) as MEq 'Market Value of Equity'
from CRSP_M as a left join crsp.msedelist (where=(missing(dlret)=0 ) ) as b
on a.permno=b.permno and
intnx('month',a.date,0,'E')=intnx('month',b.DLSTDT,0,'E')
order by date, permco, MEq;
quit;