next up previous
Next: CRSP: ncusip and cusip Up: Working with WRDS datasets Previous: CRSP: DSF/MSF


Names files in CRSP: stocknames and fundnames

Aside from the DSF and MSF files (and analogous files for mutual funds), data that changes infrequently and irregularly for each permno or crsp_fundno (like company name or ticker or exchange) is stored in names files. These files have the form, for instance

     PERMNO NAME BEGINNING_DATE ENDING_DATE
where BEGINNING_DATE is the first date on which that PERMNO has that NAME (or ticker, or ncusip, or whatever), and ENDING_DATE is the last date on which that PERMNO has that NAME.

For stocks, this file is crsp.stocknames, for funds, it is crsp.fundnames. Other files stored in this format include crsp.fund_fees and crsp.fund_style.

Consider stocknames. The BEGINNING_DATE and ENDING_DATE variables here are named NAMEDT and NAMEENDDT. To change stocknames into a dataset that can be merged with, say, msf, I can do

     data stocknames(keep=permno date ticker);
        set crsp.stocknames(keep=namedt nameenddt permno ticker);
	where namedt is not missing;
	date=intnx('month', namedt, 1)-1; 
	do while(date<=nameenddt);
	   output;
	   date=intnx('month', date+1, 1)-1;
	   end;
     run;
     data msf;
        set crsp.msf(keep=permno date ret);
	date=intnx('month', date, 1)-1;
     run;
and then merge the two by permno and date.

The statement

     date=intnx('month', namedt, 1)-1;
moves the date to the end of the month in which namedt lies.

If you do not include the ``where namedt is not missing'', missing namedts will result in an infinite loop, since SAS treats the missing value as equal to negative infinity in numerical comparisons.

There are special missing values for namedt and nameenddt given by ``.B'' and ``.E'', to indicate the ``Beginning'' of time and the ``End'' of time respectively. If you want to include these observations, you must say:

     data stocknames(keep=permno date ticker);
        set crsp.stocknames(keep=namedt nameenddt permno ticket);
	if namedt=.B then namedt='01Jan1900'd;
	if nameenddt=.E then namedt='31Dec2020'd;
	if not(missing(namedt));
	date=intnx('month', namedt, 1)-1; 
	do while(date<=nameenddt);
	   output;
	   date=intnx('month', date+1, 1)-1;
	   end;
     run;
That is, you allow SAS to read in missing values, change them appropriately, and delete observations where namedt is still missing. Notice that the statement says ``if namedt=.B'', without any quotes around ``.B''. Also notice that the ``namedt is not missing'' has become ``not(missing(namedt))''. SAS does not support the use of the ``is not missing'' construct outside where statements.


next up previous
Next: CRSP: ncusip and cusip Up: Working with WRDS datasets Previous: CRSP: DSF/MSF
Andre de Souza 2012-11-19