Accessing CRSP data on Statmart with SAS

To use CRSP Data on StatMart using the SASECRSP Interface engine:

1) Log onto StatMart (See details about SSH, using Unix, and Requesting StatMart Accounts at the Documentation Library).

2) Type crsp2003 at the command prompt. This will set up various environment variables for your Unix session that will enable CRSP utilities to run properly. You must type this each time you logon prior to using CRSP because CRSP information is not kept between Unix sessions.

3) Copy an example program from the /data/CRSP2003/SASExamples directory into your home directory. From the table below choose an example that seems closest to the task you'd like to accomplish. For example, you might type cp /data/CRSP2003/SASExamples/ex2.sas ~ to copy the second example program to your own user area (leaving the name as ex2.sas).

3a) Some of the example programs may refer to particular companies using PERMNO which is a permanent numeric identifier of companies for the businesses that the U Chicago Business School research analysts follow. (The analysts do follow a comprehensive set of companies though sometime a particular company (CUSIP) may not be directly located or identified in the CRSP database.) You may at this point gather the list of company PERMNOs that you are particularly interested in. The CRSP utility dstksearch (the Daily Stock (database) Search Utility) is easy to use to identify individual PERMNOs (and CUSIP, PERMCO (a permanent Company Identifier), etc.) if you know part of the company's name or it's ticker symbol. An illustrative dialog for finding IBM is at the bottom of this document and is found in the CRSP vendor documentation ( pg 82 of the guide titled 'CRSP Utilities Guide' an online PDF file (See link below under TS_PRINT Utility) 4) (Presuming you may want to examine companies (a set of permnos) other than those listed in the example programs or make other changes...) Edit your copy of the example SAS program using pico or vi or another editor to make small changes to the program. For example you might type pico ex2.sas then alter the range of calendar dates that are used.

5) Save your changes and exit from the editor.

6) Run the SAS program. For example you can run Example 2 and examine it's output by typing: sas ex2.sas  then pico ex2.lst If you introduced errors into the program while editing it (ex. you mispelled a variable name) the output in ex2.lst may not exist so it would then be necessary to examine ex2.log to see where and which mistake you've made, for ex. by typing: pico ex2.log

SAS example files found in /data/CRSP/SASExamples

for a small set of PERMNOs. Exports the results as a comma separated (delimited) file.
 * ex1.sas - Lists the contents (datasets and variables) in the database (as of the last month of 2003)
 * ex1.lst - Output of running ex1.sas. This file acts as a useful reference of dataset and variables names used in other programs.
 * ex2.sas - Reads daily Returns (ret), Prices(prc), and Volume(vol) in the first quarter of 1999

Note: When considering modifications to this example first use dstksearch to determine PERMNOs for various company names or CUSIP values. Or, you may also search the large text file (companies2003+.txt) which lists CUSIPS PERMNOS and Company names for companies in existence (on various Exchanges) in the past year.
 * ex3.sas - The SAS program used to make companies2003+.txt
 * ex4.sas - an example using the INSET= option to get particular companies during particular date ranges as listed in a SAS dataset
 * ex5.sas - illustrates saving a permanent SAS dataset and works from a dataset that looks at relative event dates to determine ranges.

Note: CRSP has it's own set of functions, (and formats, and informats) for converting dates into SAS Dates or integer dates (such as crspdcsd, crspds2i, crspdcid ... described online in the SAS Documentation titled 'Understanding CRSP Date Formats, Informats, and Functions' (link mentioned below) (6/16/2004 - read_ex5_out, ex6 and some examples handling dividends in CRSP will be available shortly (July))
 * read_ex5_out.sas - Reads the output dataset created from example 5 and compares two groups of companies
 * ex6.sas - merges Index data in CRSP with prices for individual companies

(Note: be sure to understand PERMNO, INSET, SETID=10, RANGE and INSET for a complete understanding of the Libname Engine usage)

Documentation Online
Main Index for SASECRSP Engine in SAS v9 http://v9doc.sas.com/cgi-bin/sasdoc/cgigdoc?file=../etsug.hlp/sasecrsp_index.htm

SASECRSP in ETS User's Guide http://v9doc.sas.com/cgi-bin/sasdoc/cgigdoc?file=../etsug.hlp/sasecrsp_sect9.htm is particularly informative - The SASECRSP Interface Engine - The LIBNAME libref SASECRSP Statement

Another technical section substantively documented is the documentation of CRSP and SAS Dates at http://v9doc.sas.com/cgi-bin/sasdoc/cgigdoc?file=../etsug.hlp/sasecrsp_sect13.htm#ets_sasecrsp_cr2uwsupp

Understanding CRSP Date Formats, Informats, and Functions

Information about lags intervals and functions for interpolation in general and dealing with Time series is at http://v9doc.sas.com/cgi-bin/sasdoc/cgigdoc?file=../etsug.hlp/tsdata_index.htm

Working with Time Series Data in the ETS Users Guide or at http://v9doc.sas.com/cgi-bin/sasdoc/cgigdoc?file=../etsug.hlp/intervals_index.htm

Date Intervals, Formats, and Functions

TS_PRINT Utility An older method of using ts_print to extract data is described in the CRSP Utilities Guide at http://statmart.cc.binghamton.edu/BU_Documentation/CRSP2001/Doc/stock_indices_utilities.pdf See pages
 * Pg12 for a list data items avilable for each company
 * Pg14-18 for an example of step to running (be sure to do steps 1 and 2 above first)
 * Pg19,24,30 Each of the 6 ts_samp.txt request file examples at

While most won't be interested in exploring options for variously shaped output, many may find the examples readcsv.sas and makecsv.txt useful because they illustrate the OUTPUT settings that will interface well with Excel dataentry and reading the output from ts_print.

Handling dividends or calculating monthly sums from the daily data may require further ellaboration that will be documented at a later time.

Using dstksearch (the Daily Stock (database) Search Utility)
A sample dialog after typing: dstksearch Enter search string: ibm

Exchange Codes 1=NYSE, 2=AMEX, 3=NASDAQ

PERMNO PERMCO CUSIP                      ... Tick EX       date range 12490 20990                              ...     IBM  1      19620702-19680101 12490 20990  45920010                    ...     IBM  1      19620102-19990103 ... 75139 22064  03093810   AMERICUS...FOR IBM ... BZP 2      19870720-19920630 ... Try another string [y] ? n