From STATMAN@PACEVM.DAC.PACE.EDU Mon Jun 17 12:51:52 1996
Date:         Mon, 17 Jun 96 15:46:36 EDT
From: Gerry <STATMAN@PACEVM.DAC.PACE.EDU>
Organization: Dept of Academic Computing, Pace University
Subject:      Format Setup Program
To: Don <DONCRAM@GSB-CROWN.STANFORD.EDU>

Don:

This program creates the DATE format file for the EVENT program. Prof
Chung's group wanted to enter dates in the form "930308", which is what
his analysis programs in FORTRAN expected. This format is very different
from what we use in the production CRSP database (Date7.).

This code is a Data Step that writes a PROC FORMAT statement for the
CRSP trading dates, putting them in YYMMDD6. format. This code is run
only once a year, when the entire CRSP database is updated.

-Gerry

-------------------- EVENT_FL SAS (Event Format Library) ----------------

/*--------------------------------------------------------------------*/
/*                Create The CRSPDATE Format Library                  */
/*--------------------------------------------------------------------*/

Options NODATE Fmtsearch=(CRSPFMT) ;

Libname CRSPFMT 'W' ;                   /* Public CRSP Format Library */

%Let NDAYS = 8180 ;   /* Change This Value After CRSP Database Update */

Data _NULL_ ;
  File 'TRADING DATES A1' ;       /* Temp File, Holds The Format Code */

  Format DATE Yymmdd6. ;     /* Format of The Trading Dates For Chung */

  /*-------------- If A CRSPDATE Library Exists, Remove It -----------*/

  Call System ('SET CMSTYPE HT') ;           /* Turn Off CMS Messages */
  ST_RC = System ('STATE 0FORMATS CRSPDATE A') ; /* Check For Library */
  Call System ('SET CMSTYPE RT') ;            /* Turn On CMS Messages */

  If (ST_RC = 0) Then                              /* If Yes, Delete  */
     Call System ('ERASE 0FORMATS CRSPDATE A') ;   /* The Old Library */

  /*----------------- Link To The CRSP Database Disks ----------------*/

  RC = System ('EXEC DATABASE (CRSP) NOMSG') ;        /* Link To CRSP */

  If (RC > 0) Then                       /* Can't Access The Database */
     Do ;
       File LOG ;
       Put // '----------------------------------------------' //
              '*** Unable To Access The CRSP Database Disks !' //
              '----------------------------------------------' // ;
       Abort 99 ;
       Stop ;                                 /* Terminate Processing */
     End ;

  /*------------------ Generate The PROC FORMAT Code -----------------*/

  Put @1 'Proc FORMAT Library=CRSPDATE ;' ;

  Do I = 1 To &NDAYS By 1 ;

     DATE = Input(Put(I, TRDATE.), Date7.) ;

     If (I = 1) Then
        Put @3 'Invalue DATENO'  @19 "'"  @20 DATE
            @26 "'"              @28 '='  @30 I 4. ;
       Else
        Put @19 "'"  @20 DATE  @26 "'"  @28 '='  @30 I 4. ;

  End ;

  Put @19 'Other' @28 "=" @30 '.  ;' / @1 'Run ;' ;

  /*--- Release The CRSP Disks And Generate The New Format Library ---*/

  RC = System ('EXEC DATABASE (DET2)') ;

  Call Execute ('%INCLUDE "TRADING DATES A1" ;') ;
  Call Execute ('CMS ERASE TRADING DATES A1 ; RUN ;') ;

 Stop ;                            /* All Done -- We're Out of Here ! */
Run ;

