Item Functions

The structure of a program using the item handling functions takes the baskc form:

  • Declare a CRSP_ITM_HNDL pointer for an app_id and initialize to NULL.
  • Call the crsp_itm_init function to initialize the handle given the app_id and the database path. This will load all the reference data and open a shell of the database.
  • Call the item load functions one or more times to select items of interest. crsp_itm_load should be sufficient for most usage. This will prepare the database and attach each item to its data location.
  • There are five handle configuration flags that can be set to affect the behavior or the item handling. Each has a default value set during the initialization, but can be modified by setting a field in the handle.
    • Keytype – determines the keys used to select data in read functions. Supported keytypes for the application are included in the reference data. A default will be set.
    • Keyset_disp_cd – determined whether keyset items are labeled by the keyset number (NUM), the keyset tag (TAG), or the expanded list of all items comprising the keyset (EXP). The default display is TAG.
    • Fiscal_disp_cd – determines whether fiscal-based time series items are reported on a calendar basis (C) or a fiscal basis (F). The default it C.
    • Curr_disp_cd – determines whether monetary values are reported in the currency reported by Compustat (REP) or in US Dollars (USD). The default currency display code is REP.
    • Grp_fill_cd – determines whether group item lists are filled so that every selected item is included for every selected keyset (Y or N). The default is Yes (Y).
  • Call a function to load the key data into the handle and call crsp_itm_get as many times as needed to read desired data.
    • User can use crsp_itm_set_key to set individual input key items of interest or crsp_itm_parse_key to pass a string and have it parsed into one or more input key items.
    • The crsp_itm_read function will load all data according to items loaded and key information specified. The user can retrieve the value for any of the found keys after the read function with crsp_itm_get_key.
  • Processing of data is usually done after the appropriate get is excecuted and data are loaded. A user can process data by traversing the groups and the item lists, or use one of the item indexes created to find a specific item and process it. Since a get function can affect either master or detail data, the program must rely on the status to determine whether a class of data was changed by the get and then process it accordingly.
  • Call the crsp_itm_close function to close the handle and free its data.