Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The SASECRSP Interface Engine

The LIBNAME libref SASECRSP Statement

LIBNAME libref SASECRSP 'physical name' options;
The CRSP environment variable CRSPDB_SASCAL must be defined to allow the SASECRSP engine access to the CRSPAccess database calendars. Often your CRSPDB_SASCAL will be pointing to the same path as your physical name. You must use a fully qualified pathname. Your physical name must end with either a forward slash if you are on a UNIX system, or a backward slash if you are on WINNT.

For a more complete description of SASECRSP set names, key fields, and date fields, see Table 1.1.

The following options can be used in the LIBNAME libref SASECRSP statement:

SETID=crsp_setidnumber
specifies the CRSP set ID number where 10 is the daily data set ID and 20 is the monthly data set ID number. Two possible values for crsp_setidnumber are 10 or 20. The SETID limits the frequency selection of time series that are included in the SAS data set. SETID is a required option for the SASECRSP engine. Depending on your host system, both should end in either a forward slash (UNIX) or a backward slash (WINNT).

For more details about the CRSPAccess crsp_setidnumber, refer to "Using Multiple Products" in the CRSPAccess Database Format Installation Guide. As an example, to access monthly data, you would use the following statements:

   LIBNAME myLib sasecrsp 'physical-name' 
      SETID=20;


PERMNO=crsp_permnumber
By default, the SASECRSP engine reads all PERMNOs in the CRSPAccess database that you name in your SASECRSP libref. You can limit the time series read from the CRSP database by specifying the PERMNO= option on your LIBNAME statement. From a performance standpoint, the PERMNO= option does random access and reads only the data for the PERMNOs listed. There is no limit to the number of crsp_permnumber options that you can use. As an example, to access monthly data for Microsoft Corporation and for International Business Machine Corporation, you could use the following statements:

   LIBNAME myLib sasecrsp 'physical-name' 
      SETID=20
      PERMNO=10107
      PERMNO=12490;


RANGE='crsp_begdt-crsp_enddt'
To limit the time range of data read from the CRSPAccess database, specify the RANGE= option in your SASECRSP libref, where crsp_begdt is the beginning date in YYYYMMDD format and crsp_enddt is the ending date of the range in YYYYMMDD format. From a performance standpoint, the engine reads all the data for a company and then restricts the data range before passing it back.

As an example, to access monthly data for Microsoft Corporation and for International Business Machine Corporation for the first quarter of 2000, you could use the following statements:

   LIBNAME myLib sasecrsp 'physical-name' 
      SETID=20
      PERMNO=10107
      PERMNO=12490
      RANGE='19990101-19990331';


INSET='setname[,keyfieldname][,keyfieldtype][,date1field][,date2field]'
When you specify a SAS data set named setname as input for issues, the SASECRSP engine assumes a default PERMNO field containing selected CRSP PERMNOs is present in the data set. If optional parameters are included, the first one is the CRSPAccess supported key name, and the second is the key type. The third optional parameter is the beginning date or event date, and the fourth is the ending date in YYYYMMDD format.

For more details about the CRSPAccess keyfields and keyfieldtypes, refer to "Stock and Indices Data Structures" in the CRSP Data Description Guide.

The following example might be used to extract the data for a portfolio of four companies to access monthly data where the range of dates is left open:

   data testin1;
      permno = 10107; output;
      permno = 12490; output;
      permno = 14322; output;
      permno = 25788; output;
   run;

   LIBNAME mstk sasecrsp 'physical-name' 
      SETID=20
      INSET='testin1';      

   data a;
      set mstk.prc;
   run;

   proc print data=a;
   run;


Suppose you want to restrict the dates for each PERMNO specifically. The example below shows how to specify the INSET= option with the 'setname[,keyfieldname][,keyfieldtype][,date1field][,date2field]' parameters:

   data testin2;
      permno = 10107; date1 = 19990101; date2 = 19991231; output;
      permno = 12490; date1 = 19970101; date2 = 19971231; output;
      permno = 14322; date1 = 19990901; date2 = 19991231; output;
      permno = 25788; date1 = 19950101; date2 = 19950331; output;
   run;

   LIBNAME mstk2 sasecrsp 'physical-name' 
      SETID=20
      INSET='testin2,PERMNO,PERMNO,DATE1,DATE2';

   data b;
      set mstk2.prc;
   run;
   
   proc print data=b;
   run;


Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.