qcew-database / README.md
Nason's picture
Clarify dataset units, query setup and snapshot caveats
f40011e verified
|
Raw History Blame Contribute Delete
17.6 kB
---
license: other
license_name: public-domain
license_link: https://www.bls.gov/opub/copyright-information.htm
pretty_name: QCEW 2025 Annual Employment and Wages
tags:
- qcew
- bls
- employment
- wages
- naics
- labor
- duckdb
size_categories:
- 1M<n<10M
---
# QCEW 2025 Annual Employment and Wages
A version-pinned DuckDB edition of the U.S. Bureau of Labor Statistics [Quarterly Census of Employment and Wages](https://www.bls.gov/cew/downloadable-data-files.htm), 2025 annual averages: **3,096,467 rows across 6 tables (48 columns)**, all 3,089,813 annual source rows plus five version-matched reference tables and a disclosure-aware view.
Use it for descriptive questions about covered employment, establishments and nominal pay by place, industry and ownership. It is establishment-based industry data, not occupational wages, unique people, an employer panel or a causal analysis.
Built with [qcew-database](https://github.com/ian-nason/qcew-database). Published to Hugging Face on 2026-10-18. The dataset is included in the public datapond catalog as `qcew`. Use normal package discovery and connections, or the immutable direct URL below.
[Quick start](#quick-start) · [Tables](#tables) · [Views](#pre-built-views) · [Examples](#example-queries) · [Caveats](#researcher-caveats) · [Source](#data-source-and-version) · [License](#license-and-attribution) · [Changelog](#changelog)
## Quick Start
Choose one route: the [datapond package](#datapond-package) finds the database by catalog ID; the direct [Python](#python-duckdb), [R](#r-with-dbi-and-duckdb) and SQL examples use a fixed artifact URL. These are alternatives, not steps that must all be run. The SQL block requires a DuckDB SQL client.
### DuckDB CLI
```sql
SET memory_limit = '128MiB';
SET threads = 1;
SET max_temp_directory_size = '0B';
INSTALL httpfs;
LOAD httpfs;
ATTACH 'https://huggingface.co/datasets/Nason/qcew-database/resolve/334c467dba413928233fb1d8cd1c0ff8de5c0105/qcew.duckdb' AS qcew (READ_ONLY);
-- The one published national all-industry, all-ownership total. Never sum the whole table.
SELECT area_title, annual_avg_estabs, annual_avg_emplvl, total_annual_wages, avg_annual_pay
FROM qcew.annual
WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10'
AND agglvl_code = '10' AND size_code = '0' AND year = '2025' AND qtr = 'A';
```
The database file is 186.5 MiB. Filtered queries fetch only the byte ranges they touch; an unfiltered scan of `annual_raw` reads most of the file, so download it locally if you plan to scan repeatedly. File size is disk storage, not a RAM estimate. Remote queries still run on your machine and can transfer much of the file. A filter or `LIMIT` after a join or aggregate does not guarantee a small scan. The 128 MiB setting limits DuckDB's buffer pool, not the whole Python/R process; with spill disabled, a larger query can fail at that limit. Download only if you have room for the file, temporary download bytes and any existing copy.
The examples use this immutable artifact URL:
```
https://huggingface.co/datasets/Nason/qcew-database/resolve/334c467dba413928233fb1d8cd1c0ff8de5c0105/qcew.duckdb
```
### Python (duckdb)
Install the Python dependency once in the environment that runs your query: `python -m pip install duckdb`.
```python
import duckdb
con = duckdb.connect(config={"memory_limit": "128MiB", "threads": "1", "max_temp_directory_size": "0B"})
con.sql("INSTALL httpfs; LOAD httpfs;")
con.sql("ATTACH 'https://huggingface.co/datasets/Nason/qcew-database/resolve/334c467dba413928233fb1d8cd1c0ff8de5c0105/qcew.duckdb' AS qcew (READ_ONLY)")
con.sql("SELECT * FROM qcew._metadata").show()
con.sql("""
SELECT area_fips, area_title, annual_avg_emplvl, avg_annual_pay, disclosure_code
FROM qcew.annual
WHERE agglvl_code = '74' AND own_code = '5' AND industry_code = '62'
AND right(area_fips, 3) <> '999' AND annual_avg_emplvl > 0
ORDER BY annual_avg_emplvl DESC, area_fips LIMIT 20
""").show()
con.close()
```
### R with DBI and duckdb
Install the R dependencies once: `install.packages(c("DBI", "duckdb"))`.
```r
library(DBI)
con <- dbConnect(duckdb::duckdb(config = list(memory_limit = "128MiB", threads = "1", max_temp_directory_size = "0B")))
dbExecute(con, "INSTALL httpfs")
dbExecute(con, "LOAD httpfs")
dbExecute(con, "ATTACH 'https://huggingface.co/datasets/Nason/qcew-database/resolve/334c467dba413928233fb1d8cd1c0ff8de5c0105/qcew.duckdb' AS qcew (READ_ONLY)")
dbGetQuery(con, "SELECT area_fips, area_title, annual_avg_emplvl, avg_annual_pay
FROM qcew.annual
WHERE agglvl_code = '55' AND own_code = '5' AND industry_code = '621'
ORDER BY annual_avg_emplvl DESC NULLS LAST, area_fips")
dbDisconnect(con, shutdown = TRUE)
```
In the tested R DuckDB 1.5.5 configuration, BIGINT and DECIMAL results are exposed as doubles. Employment and wage integers here are below 2^53 and exact; location quotients and percentage changes may be approximate in R although the stored DECIMAL values are exact.
### datapond package
Install or upgrade the Python client with `python -m pip install --upgrade datapond`, or install the released R client from [CRAN](https://cran.r-project.org/package=datapond) with `install.packages("datapond")`. Remote examples are tested with Python datapond 0.1.5 (DuckDB 1.5.4) and CRAN R datapond 0.1.0 (DuckDB 1.5.5); older DuckDB reader versions are not verified here. R 0.1.1 is a separate development version, not the CRAN release.
The examples below use the public default catalog. For limits set before attachment, use the direct DuckDB examples above; package examples here set limits immediately after connecting:
```python
import datapond
print(datapond.list())
datapond.describe('qcew', table='annual_raw')
con = datapond.connect('qcew')
con.execute("SET memory_limit='128MiB'; SET threads=1; SET max_temp_directory_size='0B'")
con.sql("SELECT annual_avg_emplvl, total_annual_wages FROM annual WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10' AND agglvl_code = '10'").show()
con.close()
```
```r
library(datapond)
dp_list()
con <- dp_connect('qcew')
DBI::dbExecute(con, "SET memory_limit='128MiB'; SET threads=1; SET max_temp_directory_size='0B'")
dp_describe(con, table = 'annual_raw')
DBI::dbGetQuery(con, "SELECT annual_avg_emplvl, total_annual_wages FROM annual WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10' AND agglvl_code = '10'")
dp_disconnect(con)
```
For repeated scans, download once and connect locally:
```python
import datapond
datapond.download('qcew')
con = datapond.connect('qcew', local=True)
con.sql("SELECT annual_avg_emplvl, total_annual_wages FROM annual WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10' AND agglvl_code = '10'").show()
con.close()
```
```r
library(datapond)
dp_download('qcew')
con <- dp_connect('qcew', local = TRUE)
DBI::dbGetQuery(con, "SELECT annual_avg_emplvl, total_annual_wages FROM annual WHERE area_fips = 'US000' AND own_code = '0' AND industry_code = '10' AND agglvl_code = '10'")
dp_disconnect(con)
```
Verify the recorded artifact SHA-256 after downloading. In Python datapond 0.1.5 as well as 0.1.1, the optional `huggingface_hub` download path follows the repository default branch rather than the pinned URL. For an exact-version copy, download the immutable URL shown above and verify its checksum; see [consumer verification](https://github.com/ian-nason/qcew-database/blob/main/docs/CONSUMERS.md) for the tested configuration.
Default-catalog discovery and representative remote queries were verified after the registry merge. Earlier full-download checks used an isolated candidate registry. See [consumer verification](https://github.com/ian-nason/qcew-database/blob/main/docs/CONSUMERS.md) for exact client versions, paths, resource limits and download behavior. The direct URL examples above work independently of the catalog. The SQL examples below use the `qcew` catalog alias from the direct-URL quick start.
## Tables
One annual data row is one area × ownership group × industry × aggregation level × size class for 2025. These rows include overlapping totals and detail; choose one level before summing. Start with the `annual` view so suppressed measures become NULL.
| Table | Description | Rows | Columns |
|---|---|---:|---:|
| `annual_raw` | 2025 annual QCEW rows preserving all 38 source fields, numeric placeholders and disclosure flags. Mixed nested geographies, industries and ownership totals; do not sum unfiltered | 3,089,813 | 38 |
| `areas` | Distinct exact area code/title pairs from the pinned 2025 BLS by-area archive | 4,451 | 2 |
| `industries` | Distinct exact industry code/title pairs from the pinned archive | 2,159 | 2 |
| `aggregation_levels` | Distinct exact aggregation-level code/title pairs | 36 | 2 |
| `ownerships` | Distinct exact ownership code/title pairs | 7 | 2 |
| `size_classes` | Code 0, all establishment sizes | 1 | 2 |
The raw key is `(area_fips, own_code, industry_code, agglvl_code, size_code, year, qtr)`. All key fields are text, including leading-zero FIPS codes; `year='2025'`, `qtr='A'` (annual, not a fifth quarter), `size_code='0'`. Reference tables cover codes used in this snapshot, not a historical code list; every code had one exact title. `_metadata` has one row per data table; `_columns` carries column definitions.
## Pre-built Views
| View | What it does |
|---|---|
| `annual` | `annual_raw` with the full key, five labels joined through the unique dictionaries, and the three disclosure flags applied independently |
In `annual`, `disclosure_code='N'` sets employment, wages, contributions, weekly wage and annual pay to NULL; `lq_disclosure_code='N'` nulls the six location quotients; `oty_disclosure_code='N'` nulls the over-the-year changes. The four establishment measures (`annual_avg_estabs`, `lq_annual_avg_estabs`, `oty_annual_avg_estabs_chg`, `oty_annual_avg_estabs_pct_chg`) are always retained as published. `annual_raw` keeps every source value, including placeholder zeroes on suppressed rows. The view is not counted in the row and table totals above.
## Example Queries
County disclosure coverage for private health care and social assistance, including valid establishment counts on suppressed rows:
```sql
SELECT disclosure_code, count(*) AS source_cells,
count(annual_avg_emplvl) AS published_employment_cells,
sum(annual_avg_estabs) AS published_establishments_rounded
FROM qcew.annual
WHERE agglvl_code = '74' AND own_code = '5' AND industry_code = '62'
AND right(area_fips, 3) <> '999'
GROUP BY disclosure_code ORDER BY disclosure_code;
```
State private ambulatory health care (NAICS 621) with published year-over-year change and its own flag:
```sql
SELECT area_fips, area_title, annual_avg_emplvl, avg_annual_pay,
oty_annual_avg_emplvl_pct_chg, oty_disclosure_code
FROM qcew.annual
WHERE agglvl_code = '55' AND own_code = '5' AND industry_code = '621'
ORDER BY annual_avg_emplvl DESC NULLS LAST, area_fips;
```
Compare two disjoint subsectors after fixing the grain to one row per county and industry:
```sql
WITH selected AS (
SELECT area_fips, area_title, industry_code, annual_avg_emplvl, avg_annual_pay
FROM qcew.annual
WHERE agglvl_code = '75' AND own_code = '5'
AND industry_code IN ('621', '622') AND right(area_fips, 3) <> '999'
)
SELECT a.area_fips, a.area_title,
a.annual_avg_emplvl AS ambulatory_jobs, h.annual_avg_emplvl AS hospital_jobs,
a.avg_annual_pay AS ambulatory_pay, h.avg_annual_pay AS hospital_pay
FROM selected a JOIN selected h ON a.area_fips = h.area_fips
WHERE a.industry_code = '621' AND h.industry_code = '622'
ORDER BY a.area_fips LIMIT 20;
```
The full set is in [examples.sql](https://github.com/ian-nason/qcew-database/blob/main/examples.sql); saved results are bound to the artifact hash.
## Researcher Caveats
1. **Suppression flags are independent and partial.** Three flags (`disclosure_code`, `lq_disclosure_code`, `oty_disclosure_code`) each govern their own measures. There are 1,860,359 suppressed level rows, 1,872,172 suppressed quotient rows and 1,937,791 suppressed change rows. Suppressed rows still carry valid establishment counts. Never read a suppressed zero as zero employment or pay.
2. **Suppressed cells are inside published totals.** Summing disclosed detail gives an incomplete total; the view does not estimate or back out suppressed values. Report how many eligible cells have published values ([BLS disclosure note](https://www.bls.gov/cew/publications/employment-and-wages-annual-averages/2025/home.htm#disclosure-restrictions)).
3. **Rows overlap; choose one level.** National, state, county, metro and combined-area rows overlap, industry totals nest, and ownership 0 (total), 8 (total government) and 9 (UI covered excluding federal) overlap sectors 1, 2, 3 and 5. Filter on `agglvl_code` (for example 74 county/sector/ownership, 75 county/3-digit, 55 state/3-digit), not on code length.
4. **Geography moves.** Connecticut uses planning-region codes from 2024 data; codes ending `999` are unallocated. Check `areas` before fixing a study universe.
5. **Industry is 2022 NAICS.** `62` is health care and social assistance; `621` ambulatory care; `622` hospitals. Do not splice historical series without checking classification changes.
6. **Employment counts covered jobs, not people.** A worker with two covered employers counts twice; the self-employed and other uncovered groups are absent. Annual employment averages 12 monthly levels; establishments average four quarters; rounding can break exact additivity.
7. **Pay is a nominal ratio.** Average annual and weekly pay are not hourly wages and not additive; do not average county pay to estimate national pay or build weighted aggregates where components are suppressed.
8. **Changes are published, not computed.** Over-the-year fields come from BLS and reflect revisions, reclassification and coverage changes; they are not causal effects. There is no separate 2024 table.
9. **Published zeros can be structural.** Some taxable-wage and contribution fields do not apply to particular ownerships, so a zero is not necessarily economic absence.
10. **Source anomalies remain visible.** DC codes 11000 and 11001 both carry “District of Columbia, not unknown”. Los Angeles County’s private health care/social assistance row has 287,445 establishments and 859,824 jobs; this snapshot does not establish why the establishment count is unusually large.
## Data Source and Version
Bureau of Labor Statistics, Quarterly Census of Employment and Wages, 2025 annual singlefile, acquired 2026-10-18. Pinned source ZIP: 62,799,396 bytes, SHA-256 `94ebbc589b1b500671c1fd507e2589a9eeb24dcd30eb07f1ce37b0018643f865`; labels derived from the official 2025 annual-by-area ZIP (114,997,862 bytes). Both archives were last modified by BLS on August 21, 2026. The national row reports 155,732,363 jobs and $12,259,226,899,972 in wages. BLS may revise annual files; this is the exact acquired snapshot, with no automatic refresh promised.
Artifact: `qcew.duckdb`, 195,571,712 bytes, SHA-256 `89bf1cef54f42f821965df6e9079b24fc7c4c0c86046fadc98e6cedf9ebd8a1d`, dataset commit `334c467dba413928233fb1d8cd1c0ff8de5c0105`.
## License and Attribution
BLS data are public domain; BLS requests source attribution ([BLS copyright information](https://www.bls.gov/opub/copyright-information.htm)). Cite: U.S. Bureau of Labor Statistics, Quarterly Census of Employment and Wages, 2025 annual, acquisition date and artifact hash. This derivative changes representation, adds dictionaries, metadata and the `annual` view, and preserves all source values in `annual_raw`. No BLS endorsement is implied.
## GitHub, Dictionary and Website
[Detailed researcher guide](https://github.com/ian-nason/qcew-database/blob/main/docs/RESEARCHER-GUIDE.md) · [Build and update instructions](https://github.com/ian-nason/qcew-database/blob/main/docs/REPRODUCE.md) · [Verified publication](https://github.com/ian-nason/qcew-database/blob/main/PUBLICATION.md)
- Source, build scripts, tests and evidence: [github.com/ian-nason/qcew-database](https://github.com/ian-nason/qcew-database)
- Column dictionary (all 48 columns, source headers, types, NULL shares, join hints): [DICTIONARY.md](https://github.com/ian-nason/qcew-database/blob/main/DICTIONARY.md); BLS [annual layout](https://www.bls.gov/cew/about-data/downloadable-file-layouts/annual/naics-based-annual-layout.htm)
- Catalog: [datapond registry](https://github.com/datapond-db/registry); `qcew` is included in the public catalog and on the [datapond website](https://datapond-db.github.io/website/).
## Changelog
### 2026-10-18 — Documentation refresh
- Added Python/R quick starts, table descriptions and column counts, view guidance, navigation, and clearer researcher caveats.
- Database bytes, schema, source locks and validated query results are unchanged. Catalog integration was pending at this documentation checkpoint; it is now complete.
### 2026-10-18 — Initial release
- QCEW 2025 annual: 3,096,467 rows across 6 tables (48 columns) and the `annual` view. Artifact 195,571,712 bytes, SHA-256 `89bf1cef…edbf8a1d`, commit `334c467d`.
- Every typed cell verified against an independent read of the pinned source ZIP; disclosure NULLs checked against their own flags; public immutable URL, HTTP range requests and the installed Python and R clients tested after upload.
- Registry entry initially opened as a draft pull request; later merged after integration review.