Downloads financial statement data from Compustat with standard filters for clean, analysis-ready data.
Arguments
- wrds
A
DBIConnectionobject returned bywrds_connect().- frequency
One of
"annual"(default) or"quarterly".- region
One of
"na"(North America, default) or"global".- start_date
Start date for filtering. Character string in
"YYYY-MM-DD"format or a Date object. Defaults toNULL(no filter).- end_date
End date for filtering. Character string in
"YYYY-MM-DD"format or a Date object. Defaults toNULL(no filter).- columns
Character vector of columns to return, replacing the defaults. Use
describe_table()to see available columns.- add_columns
Character vector of additional columns to include beyond the defaults. Ignored if
columnsis specified.- indfmt
Industry format filter. Defaults to
"INDL"(industrial). Use"FS"for financial services format.- consol
Consolidation level. Defaults to
"C"(consolidated). Use"B"for both consolidated and non-consolidated.- fill_sic
If
TRUE, fills missing historical SIC codes (sich) with header SIC codes fromcomp.company. Only supported for North America. When used withlazy = TRUE, returns the table withsichbut without the join (requires manual joining withget_company()). Defaults toFALSE.- 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 Compustat fundamentals. Default columns vary by region:
North America (from comp.funda / comp.fundq):
Identifiers:
gvkey,cusip,tic,conm,datadateTime:
fyear/fyearq,fyr/fqtrIncome:
ni/niq,ib/ibq,oiadp/oiadpq,revt/revtqBalance sheet:
at/atq,lt/ltq,seq/seqq,ceq/ceqqMarket:
csho/cshoq,prcc_f/prccqOther:
sale/saleq,capx/capxy,che/cheq,dlc/dlcq,dltt/dlttqIndustry:
sich(historical SIC);sic(whenfill_sic = TRUE, coalesced fromsichand header SIC)
Global (from comp.g_funda / comp.g_fundq):
Identifiers:
gvkey,isin,conm,datadateGeography:
loc,fic,exchgSimilar financial variables (with some differences, e.g.,
nit/nitqinstead ofni/niq)
Details
Default filters follow standard practice for most research applications.
Region-specific filters are applied automatically based on region:
datafmt:"STD"for North America,"HIST_STD"for Globalpopsrc:"D"(domestic) for North America,"I"(international) for Global
North America and Global data have different structures and should not be combined without careful column harmonization.
See also
link_ccm() for CRSP-Compustat linking, get_company() for
company header data
Examples
if (FALSE) { # \dontrun{
wrds <- wrds_connect()
# Annual North America fundamentals
funda <- get_compustat(wrds)
# Quarterly with date filter
fundq <- get_compustat(wrds,
frequency = "quarterly",
start_date = "2020-01-01",
end_date = "2023-12-31"
)
# Global annual
g_funda <- get_compustat(wrds, region = "global")
# Lazy query for further filtering
get_compustat(wrds, lazy = TRUE) |>
dplyr::filter(fyear >= 2020) |>
dplyr::select(gvkey, datadate, at, lt) |>
dplyr::collect()
# Fill missing SIC codes with header SIC from comp.company
funda_sic <- get_compustat(wrds, fill_sic = TRUE)
# Preview first 100 rows before full download
preview <- get_compustat(wrds, n = 100)
wrds_disconnect(wrds)
} # }