stk_print: Stock Database Report Writer
Introduction
stk_print is a command-line utility that can be used to access CRSPAccess stock data on all supported platforms. It is useful for browsing data formatted for a terminal or extracting data formatted for program input. It supports CRSP stock header, event, and time-series data items and supports individual securities typed at a terminal, securities in an input file, or all securities in the database. The user selects input and output options on the command line. If security identifiers are typed at the terminal, input or output options can be switched between each entry. Output can be printed to a terminal or saved in a file.
Use one of the following commands to run stk_print:
- dstkprint - to read the daily CRSP database
- stkprint - to read the daily CRSP database
- mstkprint - to read the monthly CRSP database
- stk_print /d1 database.name [options] - to access an alternative (non-default) daily database
- stk_print /d1 database.name /fm [options] - to access an alternative (non-default) monthly database
stk_print Options and Output Headers
Click here for a complete list of data items available in stk_print, including the options that can be used to access them, and the headers that identify them in program output.
Click here for a list of stk_print options grouped by usage category.
stk_print Usage and Examples
Normal usage is to type identifiers at the command line once the program is started. A full database, or a subset specified in an input file, can also be processed sequentially with stk_print.
You can locate PERMNOs or other supported identifiers for the security that you wish to enter by using the stk_search utility. See Search and Inquiry Tools for usage details.
Options to select different identifiers, data, date ranges, or output options can be added either at the command line or after the program is started. To browse the data, type selected data items within the program for the desired company data. The following example would extract name history, and daily prices and returns for Microsoft from April June, 2002.
CRSP3>stkprint CRSP NYSE/Amex/NASDAQ Daily History + Indexes, data ending 20020628 Using default dates 20020328 - 20020628 Enter identifier or new option beginning with slash. Type ? for help. /npppr Keep previous data options? (y/n) n options have been reset. Enter identifier or new option beginning with slash. Type ? for help. 10107
To export data for additional processing, enter all desired parameters on the command line. This example would extract the name history data and daily prices and returns for the securities in the companies.inp file from April June, 2002. The output is then written to a file, sample.out.
CRSP3>stk_print /npppr /of sample.out /if companies.inp
Stk_print Options
Time series items may be access in stk_print by two methods:
/ml "
<.keyset1> [; <.keyset 2>.]" Individual items are specified. Command line length limits the number of items that can be specified with this option.
/mf item.file
An input text file is supplied which contains one row per selection, each with
<.keyset>.
Keyset is optional and is used with portfolios and groups. If not given, the item's default is assumed. It can take the form of a list (#[,#[-#]]...) or an asterisk.
Both /ml and /mf methods can be used at the same time. The order they appear in the request determines the order in the output. In both cases, item names are not case sensitive.
Keyset Usage for Stock
The portype and grouptype values for Portfolios (/dy) and Groups (/gp) may be accessed as either porttype and grouptype values or keyset offsets.
Daily porttype values 1-9 equate to keyset values 101- 109
Monthly porttype values 1-8 equate to keyset values 201-208
Grouptype values 1-50 equate to keyset value 301-350. Note that S&P 500 Constituents is the only valid group, represented by grouptype 16 or keyset 316.
The advantage to using keyset offsets is that they provide unique values across all frequencies of databases. Stk_print maintains an offset for each group so the user can specify the porttype or grouptype or the actual keyset. If the value is nonzero and less than 100, the offset is applied, so the value or keyset notation selects the same series.
Keysets are supplied as a period followed by a * for all, or a list for specific selections. If there is no period, then the default is used. For example, /dy or /dy.1 or /dy.101 all will get portfolio type 1 (daily keyset 101) and /dy.* will get all portfolios.
Output Format Changes
Formats are fixed and set based on reference data instead of predefined fixed formats. For some types of data (names) the same items may not fit the same way on 80-character windows, and the headers could have different text and width. Pipe-delimited output can have format changes to more standardized precision. Floating point numbers are now printed with scientific notation in pipe-delimited output formats.