|
Chapter Contents |
Previous |
Next |
| The SASECRSP Interface Engine |
CRSP has historically used two different methods to represent dates, while SAS has used a third. The three formats are SAS Dates, CRSP Dates, and Integer Dates. The SASECRSP engine provides 22 functions, 15 informats, and 10 formats to enable you to easily translate the dates from one internal representation to another. A SASECRSP libname assign must be active to use these date access methods.
SAS dates are internally stored as the number of days since January 1, 1960. The SAS method is an industry standard and provides a great deal of flexibility, including a wide variety of informats, formats, and functions.
CRSP dates are designed to ease time series storage and access. Internally the dates are stored as an offset into an array of trading days. Note that there are five different CRSP trading day calendars: Annual, Quarterly, Monthly, Weekly, and Daily. The CRSP method provides fewer missing values and makes trading period calculations very easy. However, there are also many valid calendar dates that are not available in the CRSP trading calendars, and care must be taken when using other dates.
Integer dates are a way to represent dates that are platform independent and maintain the correct sort order. However, the distance between dates is not maintained.
The best way to illustrate these formats is with some sample data. The table below only shows CRSP Daily and Monthly dates.
Table 1.2: Date Representations for Daily and Monthly Data| Date | SAS Date | CRSP Date | CRSP Date | Integer Date |
| (Daily) | (Monthly) | |||
| July 31, 1962 | 942 | 21 | 440 | 19620731 |
| August 31, 1962 | 973 | 44 | 441 | 19620831 |
| December 30, 1998 | 14,243 | 9190 | NA* | 19981230 |
| December 31, 1998 | 14,244 | 9191 | 877 | 19981231 |
| * Not available if an exact match is requested. | ||||
Having an understanding of the internal differences in representing SAS dates, CRSP dates, and CRSP integer dates will help you use the SASECRSP formats, informats, and functions effectively. Always keep in mind the frequency of the CRSP calendar that you are accessing when you specify a CRSP date.
Here are some samples using the monthly and daily calendar as examples. The Annual (CRSPDTA and CRSPDRA), Quarterly (CRSPDTQ and CRSPDRQ), and the Weekly (CRSPDTW and CRSPDRW) work analogously.
Table 1.3: Sample CRSPDT Formats for Daily and Monthly Data| CRSP Date | CRSPDTD8. | CRSPDRD8. | CRSPDTM8. | CRSPDRM8. | |
| Date | Daily , Monthly | Daily Date | Daily Range | Monthly Date | Monthly Range |
| July 31,1962 | 21 , 440 | 19620731 | 19620731 + | 19620731 | 19620630-19620731 |
| August31,1962 | 44 , 441 | 19620831 | 19620831 + | 19620831 | 19620801-19620831 |
| December30, | 9190 , NA * | 19981230 | 19981230 + | NA* | NA* |
| 1998 | |||||
| December31, | 9191 , 877 | 19981231 | 19981231 + | 19981231 | 19981201-19981231 |
| 1998 | |||||
| + Daily ranges will look similar to Monthly Ranges if they are Mondays or immediately following a trading holiday. | |||||
| * When working with exact matches, no CRSP monthly date exists for December 30, 1998. | |||||
The five CRSPDT* informats find exact matches only. The five CRSPDR* informats look for an exact match, and if it is not found it goes forward, matching the CRSPDR* formats. The five CRSPDB* informats look for an exact match, and if it is not found it goes backward. Here is a sample using only the CRSP monthly calendar as an example, but the daily, weekly, quarterly, and annual frequencies work analogously.
Table 1.4: Sample @CRSP Date Informats Using Monthly Data
| Input Date | CRSP Date | CRSP Date | CRSP Date | CRSPDTM8. | CRSPDRM8. |
| (Integer Date) | CRSPDTM | CRSPDRM | CRSPDBM | Monthly Date | Monthly Range |
| 19620731 | 440 | 440 | 440 | 19620731 | 19620630-19620731 |
| 19620815 | .(missing) | 441 | 440 | See below+ | See below* |
| 19620831 | 441 | 441 | 441 | 19620831 | 19620801-19620831 |
| + If missing, then missing. If 441, then 19620831. If 440, then 19620731. | |||||
| * If missing, then missing. If 441, then 19620801-19620831. If 440, then 19620630-19620731. | |||||
| Function | Function | Argument | Argument | Return |
| Group | Name | One | Two | Value |
| CRSP dates to Integer dates for December 31, 1998 | ||||
| Annual | crspdcia | 74 | None | 19981231 |
| Quarterly | crspdciq | 293 | None | 19981231 |
| Monthly | crspdcim | 877 | None | 19981231 |
| Weekly | crspdciw | 1905 | None | 19981231 |
| Daily | crspdcid | 9191 | None | 19981231 |
| CRSP dates to SAS dates for December 31, 1998 | ||||
| Annual | crspdcsa | 74 | None | 14,244 |
| Quarterly | crspdcsq | 293 | None | 14,244 |
| Monthly | crspdcsm | 877 | None | 14,244 |
| Weekly | crspdcsw | 1905 | None | 14,244 |
| Daily | crspdcsd | 9191 | None | 14,244 |
| Integer dates to CRSP dates exact is illustrated, but can be forward or backward | ||||
| Annual | crspdica | 19981231 | 0 | 74 |
| Quarterly | crspdicq | 19981231 | 0 | 293 |
| Monthly | crspdicm | 19981231 | 0 | 877 |
| Weekly | crspdicw | 19981231 | 0 | 1905 |
| Daily | crspdicd | 19981231 | 0 | 9191 |
| SAS dates to CRSP dates exact is illustrated, but can be forward or backward | ||||
| Annual | crspdsca | 14,244 | 0 | 74 |
| Quarterly | crspdscq | 14,244 | 0 | 293 |
| Monthly | crspdscm | 14,244 | 0 | 877 |
| Weekly | crspdscw | 14,244 | 0 | 1905 |
| Daily | crspdscd | 14,244 | 0 | 9191 |
| Integer dates to SAS dates for December 31, 1998 | ||||
| Integer to SAS | crspdi2s | 19981231 | None | 14,244 |
| SAS dates to Integer dates for December 31, 1998 | ||||
| SAS to Integer | crspds2i | 14,244 | None | 19981231 |
|
Chapter Contents |
Previous |
Next |
Top |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.