WRDS Compustat, CRSP, and SEC EDGAR Panel Workflow Guide
A comprehensive empirical workflow for point-in-time CCM panel linking, CRSP Flat File Format 2.0 delisting handling, SEC EDGAR 10-K REST API integration, and two-way clustered standard errors.
HumanPen Team
· 11 min read
Empirical Finance Panel Construction: WRDS Compustat, CRSP, and SEC EDGAR
Merging Compustat annual fundamentals (`comp.funda`) with CRSP monthly stock files requires point-in-time CCM linking via `crsp.ccmxpf_lnkhist` using `linktype IN ('LU', 'LC')`, `linkprim IN ('P', 'C')`, and `linkdt <= datadate <= linkenddt`. Modern empirical finance and accounting workflows must also accommodate the 2025–2026 CRSP Flat File Format 2.0 (`CIZ`) transition, enforce conservative Fama–French (1992, 1993) accounting reporting lags, query SEC EDGAR REST APIs under strict fair-access limits, and estimate Petersen (2009) two-way firm and year clustered standard errors to prevent biased inference.
Accounting, finance, and corporate governance studies routinely fail at the intersection of entity-level identifiers and temporal alignment. Merging raw database extracts on static identifiers like `cusip` or uncleaned `gvkey` records introduces severe survivorship and look-ahead biases. Furthermore, failing to account for corporate restructuring, dual-class share classes, or regulatory delisting distributions creates artificial return anomalies that distort cross-sectional regressions.
Methodological precision requires scripted pipelines in R or Python that systematically document sample attrition and link validity. When structuring multi-source empirical architectures, researchers frequently consult the cleaning and panel merging workflow for Wind and CSMAR to establish reproducible data validation routines before deploying econometric estimators.
Point-in-Time CCM Linking and the CRSP 2.0 CIZ Format Transition
In empirical asset pricing and corporate finance, Compustat organizes records by corporate entity identifier (`gvkey`), while CRSP tracks individual traded issues by security identifier (`permno`) and corporate parent entities by `permco`. Merging these databases requires the CRSP/Compustat Merged (`CCM`) linking table (`crsp.ccmxpf_lnkhist`). Before performing this join, researchers must de-duplicate Compustat annual fundamentals (`comp.funda`) by filtering for standard consolidated industrial reports where `indfmt = 'INDL'`, `datafmt = 'STD'`, `popsrc = 'D'`, and `consol = 'C'`.
"Unfortunately, CRSP and Compustat use different keys to identify stocks and firms. CRSP uses permno for stocks, while Compustat uses gvkey to identify firms. Fortunately, a curated matching table on WRDS allows us to merge CRSP and Compustat, so we create a connection to the CRSP-Compustat Merged table (provided by CRSP). The linking table contains links between CRSP and Compustat identifiers from various approaches."
| Empirical Dimension | Legacy SIZ Format (1.0) | Modern CIZ Format (2.0) | Methodological Impact |
|---|---|---|---|
| Monthly Stock File | crsp.msf with msenames | crsp.msf_v2 with stksecurityinfohist | Streamlined single-file entity tracking |
| Delisting Return Integration | Manual merge with crsp.msedelist dlret | Integrated directly into mthret | Prevents upward delisting survival bias |
| Negative Price Coding | Negative prc denotes bid-ask midpoint | Non-negative price field mthprc without minus-sign flag | Eliminates accidental dropping of illiquid stocks |
| Share Type Filtering | Numeric share codes shrcd 10 and 11 | String flags sharetype NS and securitysubtype COM | Standardizes common equity selection |
| Effective Date Slicing | Named date intervals namedt to nameendt | Sliced by secinfostartdt and secinfoenddt | Requires month-end clipping guards |
- Filter `linktype IN ('LU', 'LC')` in `crsp.ccmxpf_lnkhist` to restrict the merge to verified, non-overlapping links, dropping unresearched or duplicate link types such as `'LD'`, `'LX'`, and `'NR'`.
- Enforce `linkprim IN ('P', 'C')` to select primary equity issues recognized by Compustat (`'P'`) or CRSP (`'C'`), preventing duplicate firm-year observations for dual-class companies.
- Restrict observation dates using temporal boundaries `datadate >= linkdt` and `datadate <= coalesce(linkenddt, CURRENT_DATE)` to prevent look-ahead linking errors after corporate restructuring.
- Aggregate firm-level market equity by summing `shrout × abs(prc)` across all active common stock `permno` securities sharing the same `permco` parent before attaching primary issue returns.
- Apply modern CIZ security filters on `crsp.stksecurityinfohist` using `sharetype = 'NS'`, `securitytype = 'EQTY'`, `securitysubtype = 'COM'`, `usincflg = 'Y'`, and `issuertype IN ('ACOR', 'CORP')`.
Methodological trap warning: Joining Compustat `funda` to CRSP stock tables using the static 8-digit or 9-digit `cusip` header is one of the most widespread errors in empirical research. The `funda.cusip` field is a static attribute reflecting only a company's latest identifier, overwriting historical identifiers whenever a firm reincorporates, changes its name, or undergoes a reverse split. Direct CUSIP joins silently discard merged, acquired, or restructured companies, generating severe survivorship bias that invalidates regression inference.
Accounting Reporting Lags, Sample Hygiene, and Petersen Two-Way Clustered Errors
Following Fama and French (1992, 1993), annual accounting data for fiscal years ending in calendar year `t - 1` are matched with monthly CRSP returns from July of year `t` through June of year `t + 1`. This conservative six-month lag guarantees that the market has absorbed the annual report. Sample hygiene further demands filtering out financial institutions (`SIC 6000–6999`) and regulated utilities (`SIC 4900–4999`) using historical industry codes (`sich` in Compustat or `siccd` in CRSP) rather than static header `sic`, followed by two-tailed winsorization of continuous financial ratios at the 1st and 99th percentiles.
"In corporate finance and asset pricing empirical work, researchers are often confronted with panel data. In these data sets, the residuals may be correlated across firms or across time, and OLS standard errors can be biased. Historically, researchers in the two literatures have used different solutions to this problem. This paper examines the different methods used in the literature and explains when the different methods yield the same (and correct) standard errors and when they diverge."
| Pipeline Stage | WRDS / EDGAR Target Table & Key | Exact SQL / Python / R Filter Rule | Empirical Bias Prevented |
|---|---|---|---|
| Compustat Fundamentals De-duplication | comp.funda (gvkey, datadate) | indfmt = 'INDL' AND datafmt = 'STD' AND popsrc = 'D' AND consol = 'C' | Prevents FS duplicate shadow rows and non-standard accounting formats |
| Point-in-Time CCM Linking | crsp.ccmxpf_lnkhist (gvkey -> lpermno) | linktype IN ('LU', 'LC') AND linkprim IN ('P', 'C') AND linkdt <= datadate AND datadate <= coalesce(linkenddt, CURRENT_DATE) | Prevents static-CUSIP survivorship bias and unresearched duplicate links |
| CRSP Common Equity and Delisting | crsp.msf_v2 & stksecurityinfohist (permno) | US common-equity filter (sharetype = 'NS', securitysubtype = 'COM') and integrated delisting returns in mthret | Prevents delisting upward survival bias and non-common equity distortion |
| Historical Industry Code Filter | comp.funda (sich) or crsp.msf_v2 / stksecurityinfohist (siccd) | Exclude financials (SIC 6000–6999) and regulated utilities (SIC 4900–4999) using historical sich or siccd | Prevents capital structure and regulatory rate-setting biases |
| Accounting-to-Return Lag Alignment | datadate aligned to CRSP monthly returns or SEC EDGAR filingDate | Match fiscal year `t - 1` accounting to CRSP returns from July of year `t` through June of year `t + 1` (or exact SEC `10-K` `filingDate`) | Prevents look-ahead bias caused by assuming instant public availability of year-end accounting reports |
| Cross-Sectional Outlier Treatment | Merged panel covariates (gvkey, fyear) | Cross-sectional 1st/99th percentile winsorization per fiscal year (capping extreme ratio tails at percentiles without dropping rows) | Prevents extreme ratio outlier distortion while avoiding non-random covariate drop bias |
- Fama–MacBeth (1973) regressions account for cross-sectional correlation across firms in year `t`, but dramatically underestimate standard errors when regressors or residuals exhibit persistence across years.
- Clustering standard errors solely by firm accounts for arbitrary serial correlation within a firm, but fails under common macroeconomic shocks affecting all firms in a given year.
- Petersen (2009) and Cameron, Gelbach, and Miller (2011) demonstrate that two-way clustering provides unbiased inference across both dimensions using `V_two_way = V_firm + V_time - V_white`.
- In R, estimate models with firm and year fixed effects and two-way clustered errors using `fixest::feols(y ~ x1 + x2 | gvkey + fyear, data = panel_df, vcov = ~gvkey + fyear)`.
- In Python, specify entity and time effects with two-way clustering using `linearmodels.panel.PanelOLS.from_formula('y ~ x1 + x2 + EntityEffects + TimeEffects', data = panel_df).fit(cov_type = 'clustered', cluster_entity = True, cluster_time = True)`.
- Small-cluster caveat: When panels have few time clusters (`T < 25` years), Petersen (2009) warns that clustering on time produces downward-biased variance; researchers should absorb time fixed effects and cluster solely on firm.
Researchers applying these panel structures to causal corporate policy interventions frequently pair them with a staggered difference-in-differences panel workflow. Evaluating heterogeneous treatment dynamics alongside firm-level fixed effects ensures that policy inferences remain robust against both time-varying treatment timing and multi-dimensional error correlations.
SEC EDGAR REST API Fair-Access and End-to-End Pipeline Execution
Beyond standardized accounting numbers from Compustat, modern empirical corporate finance frequently incorporates narrative disclosures and XBRL tags from SEC EDGAR filings. The SEC provides official REST endpoints via `data.sec.gov`, including filing history metadata at `data.sec.gov/submissions/CIK{10-digit-CIK}.json` and full standardized financial fact taxonomies at `data.sec.gov/api/xbrl/companyfacts/CIK{10-digit-CIK}.json`. To query these endpoints, researchers must convert Compustat `cik` identifiers into zero-padded 10-digit strings and extract exact filing dates (`filingDate`) to eliminate disclosure look-ahead bias.
"Note that our current maximum access rate is 10 requests per second. This is carefully monitored to preserve equitable access for all users. See: Internet Security Policy. Please declare your user agent in request headers: Sample Declared Bot Request Headers: User-Agent: Sample Company Name AdminContact@<sample company domain>.com"
When scaling empirical panels across decades of corporate records, local computing environments often face memory bottlenecks or syntax fragmentation between legacy Stata do-files and modern Python environments. Because WRDS Compustat and CRSP data are proprietary subscription databases governed by institutional agreements, analytical platforms cannot log into WRDS on your behalf. Researchers must export permitted extracts under their own institutional credentials and upload their files (up to 5 GB total) to HumanPen Start Project. Attach your data and papers, describe what you need, approve the plan before work starts, and get the reviewed report, charts, and code ready to preview online or download. The platform executes data merging, delisting adjustments, and multi-way fixed-effects regressions in an isolated CPU-based Python and R sandbox, retaining project files for 6 months after the last activity with full encryption in transit and anytime deletion controls.
- Export raw Compustat `funda` and CRSP `msf_v2` tables as `.parquet`, `.csv`, or `.dta` files under your university subscription before uploading to the sandbox.
- Confirm project specifications and methodological plans during the interactive review stage before computational execution begins.
- Receive reproducible Python (`polars`, `linearmodels`) or R (`fixest`) scripts alongside detailed sample attrition logs and publication-ready regression tables.
- Request iterative revisions within the active project workspace while preserving version history across previous script executions.
All generated code, sample selection logs, and econometric outputs serve strictly as an empirical reference scaffold to assist researchers in building reproducible research designs. Authors remain responsible for independently verifying variable transformations against official database documentation and disclosing technical tools in accordance with journal editorial standards. Researchers extending their corporate panels into qualitative disclosures often combine this pipeline with our ESG disclosure and annual report KPI extraction guide to benchmark narrative transparency alongside financial performance.
Frequently Asked Questions
Why does joining Compustat and CRSP using 8-digit CUSIPs drop historical acquired companies? Compustat reports the latest known CUSIP in its static `funda.cusip` header variable, overwriting previous historical identifiers whenever a corporation merges or reincorporates. Merging directly on this static field fails to match historical CRSP records (`ncusip`), silently discarding acquired or restructured firms. Researchers must join through the CCM linking table (`crsp.ccmxpf_lnkhist`) using `linktype IN ('LU', 'LC')`, `linkprim IN ('P', 'C')`, and active date intervals.
How does CRSP Flat File Format 2.0 (CIZ) change the calculation of monthly delisting returns? In legacy CRSP SIZ tables (`crsp.msf`), monthly returns in `ret` omitted delisting performance, requiring researchers to manually link `crsp.msedelist` and compute compound delisting returns `(1 + ret) × (1 + dlret) - 1`. In modern CRSP CIZ 2.0 (`crsp.msf_v2`), delisting returns are already integrated directly into the primary monthly return field `mthret`, eliminating the need for manual secondary joins.
Can analytical platforms log into WRDS directly using institutional university accounts? No. In strict compliance with proprietary database licensing terms and institutional network security boundaries, analytical platforms do not accept or store institutional WRDS credentials. Researchers must query and export permitted datasets from their university-subscribed terminals first, and then upload the resulting data files (up to 5 GB total) for automated Python or R processing.
When should empirical researchers use firm-level clustering instead of two-way clustering? Petersen (2009) demonstrates that while two-way clustering by firm and year is optimal for long panels, its asymptotic variance properties break down when the number of clusters in either dimension is small. In short panels with fewer than 25 calendar years, clustering on year produces downward-biased and unstable standard errors; researchers should absorb year fixed effects and cluster standard errors solely by firm.
Sources
- U.S. SEC — EDGAR Application Programming Interfaces — Official SEC documentation for developer REST endpoints covering submission metadata and XBRL company facts.
- U.S. SEC — Webmaster Frequently Asked Questions — Official fair-access policy mandating declared User-Agent request headers and the 10 requests per second rate limit.
- U.S. SEC — Live Submissions JSON Endpoint (Apple Inc. CIK0000320193) — Verified public-domain REST JSON endpoint for entity filing histories and accession numbers.
- Petersen (2009, Review of Financial Studies) — Estimating Standard Errors in Finance Panel Data Sets — Peer-reviewed econometric study on biases in OLS, Fama-MacBeth, and two-way clustered standard errors.
- Fama & French (1992, Journal of Finance) — The Cross-Section of Expected Stock Returns — Foundational asset pricing paper establishing the conservative June/July accounting reporting lag.
- Fama & French (1993, Journal of Financial Economics) — Common Risk Factors in the Returns on Stocks and Bonds — Classic methodology for portfolio formation and accounting variable construction.
- Tidy Finance — WRDS, CRSP, and Compustat — Open-access computational finance textbook detailing CCM linking and modern CRSP 2.0 CIZ transitions.
- CRSP US Stock Databases — Official Product Overview — Specifications for CRSP equity files, share classifications, and historical trading series.
- WRDS — Official Python Client Repository — Technical reference for connecting programmatically to WRDS PostgreSQL database backends.
- R Project — fixest::feols Reference — Package documentation for high-dimensional fixed effects and multi-way clustered standard errors.
- linearmodels — PanelOLS Model Reference — Python package documentation for panel econometric models with multi-way entity and time clustering.
KEEP READING