Downloads the CCM (CRSP-Compustat Merged) linking table that maps CRSP PERMNOs to Compustat GVKEYs with valid date ranges.
Arguments
- wrds
A
DBIConnectionobject returned bywrds_connect().- linktype
Character vector. Types of links to include. Defaults to
c("LC", "LU", "LS"):"LC": Link confirmed by Compustat"LU": Link unconfirmed (valid but less certain)"LS": Link valid for secondary securities
- linkprim
Character vector. Link primacy filters. Defaults to
c("P", "C"):"P": Primary link identified by Compustat"C": Primary link identified by CRSP
- n
Maximum number of rows to return. Defaults to
Inf(all rows). Use a smaller value (e.g.,n = 100) to preview data before downloading the full table.- lazy
If
TRUE, returns a lazytblinstead of collecting. Defaults toFALSE.
Value
A tibble with columns:
- gvkey
Compustat company identifier
- permno
CRSP permanent security identifier
- linkdt
Start date of the link
- linkenddt
End date of the link (missing values replaced with max date)
- linktype
Type of link
- linkprim
Link primacy
Details
The linking table comes from crsp.ccmxpf_lnkhist. Missing linkenddt
values indicate ongoing links and are replaced with the maximum date in the
table for easier date-range joins.
To use the link, join on gvkey and ensure your observation date falls
within the linkdt to linkenddt range.
References
Ian Gow, Financial Accounting Research, Chapter on Identifiers: https://iangow.github.io/far_book/identifiers.html
Examples
if (FALSE) { # \dontrun{
wrds <- wrds_connect()
ccm <- link_ccm(wrds)
# Join with Compustat data
compustat <- get_compustat(wrds)
compustat |>
dplyr::inner_join(ccm, by = dplyr::join_by(gvkey)) |>
dplyr::filter(datadate >= linkdt, datadate <= linkenddt)
wrds_disconnect(wrds)
} # }