Fixed-Length Binary CRSP File Conversion and Support Code CRSP ships its stock returns and master/returns files in a limited number of file formats. Many subscribers receive the character format, which takes up a lot of disk space (more than 2 GB for the 1995 DA product) and is slow to process. CRSP provides subroutines that can be used to convert the character format to a binary format that is much more compact. Unfortunately, SAS cannot correctly read the binary format on most Unix and Windows systems and some VMS systems. The basic problem is that SAS misinterprets some binary data as end-of- record characters. Arnold R. Cowan, Associate Professor of Finance at Iowa State University and President of Cowan Research, has designed an alternative binary CRSP file format. It is fixed length for compatibility with SAS, but as a flat-file binary format it preserves the advantages of compactness and access speed over character flat files or SAS data sets. Also, it uses the logic of the native CRSP character file in the way that it breaks the CRSP data vectors into records and identifies them. This allows a programmer to make use of character-CRSP techniques with fairly minimal changes. The eight FORTRAN files here, together with the CRSP-supplied routines, support creation of and FORTRAN access to the fixed- binary format. These routines are simple modifications of the FORTRAN code supplied by CRSP. They should work on Unix and OpenVMS systems with only changes to the OPEN (and possibly INCLUDE) statements in the main program. bfstk.f is the stock file conversion program. It reads in an ascii character stock file using the original CRSP CHGET subroutine and writes out the fixed-length binary file. The comments in the program indicate where the user needs to make changes. The program needs to be compiled and linked with the subprograms that it calls. On a Digital Unix system, this can be done with the command: % f77 -extend_source -o bfstk.o -O4 bfstk.f chget.f bical.f chckid.f ckdat.f cknum.f numrec.f outhdr.f bfput.f bidump.f This puts the executable code in bfstk.o. You will need to convert the stock index file also. The fixed- binary stock index file is the same as the regular binary one, so no new subroutine is needed. Just use the CRSP subroutine CHCAL to read in the character index file and BICAL to write out the binary file. However, make sure that the OPEN state- ment for the binary index file sets it up as a fixed-length (or stream_lf) unformatted file with an 11-word record length. CRSP tends to define the binary index file as variable-length even though all the records are in fact identical in length. FORTRAN users can access the fixed binary CRSP file using their familiar programs, but replacing some subprogram names with those of the modified subprograms on this site. The programs will have to be recompiled after the changes, of course. The substitutions to make are: Type Original CRSP Character Fixed Binary Replacement include file allincls fallincl include file nmsfl fnmsfl subroutine chget bfget subroutine chgetn bfgetn The following are less commonly seen by the end user, but the indicated substitution must be made when they are present in the user program. Type Original CRSP Character Fixed Binary Replacement include file parmsfl fparmfl subroutine chput bfput subroutine chputn bfputn Comments, suggestions, bugs and questions may be sent to the author (mailto:arnie@iastate.edu). As there is more CRSP than Cowan in the code files, any CRSP subscriber may use them freely except for purpose of commercial sale of the code itself. This document copyright (c) 1996 Arnold R. Cowan; all rights reserved.