# Data Sources & Use

All data in this folder come from **public U.S. and Texas government sources** and are in the public domain. The processed datasets and build code may be freely used, shared, and adapted for teaching and research. Please credit the original agencies below.

## Sources

| Source | Used for | Access |
|---|---|---|
| **Texas Comptroller of Public Accounts** — open data portal (`data.texas.gov`) | Sales-tax allocation by city (`vfba-b57j`); city–county sales-tax rate (`53pa-m7sm`); quarterly taxable sales & business outlets (`7z4d-yf2c`) | Socrata CSV/JSON API, no key |
| **U.S. Census Bureau — 2022 Census of Governments**, Survey of Local Government Finances, Individual Unit File | Population, property/total taxes, long- and short-term debt outstanding | Public-use ZIP, no key |
| **U.S. OMB / Census Bureau — Core Based Statistical Area (CBSA) delineation, 2023** | Metropolitan / Micropolitan classification of counties | Public XLSX, no key |
| **U.S. Bureau of Labor Statistics — CPI-U**, U.S. city average, all items, annual averages | Constant-2024-dollar (real) columns | Published annual averages |

## Reproducibility

The datasets are fully regenerated by the scripts in [`../scripts`](../scripts):

```bash
pip install pandas requests openpyxl
cd scripts
python3 build_panel.py      # primary annual panel
python3 build_dataset.py    # 2022 cross-section (with debt)
python3 validate.py         # 19 integrity checks (run from Datasets/)
```

Each build script downloads its source files to `_raw/` on first run (no API key required) and writes CSV + XLSX outputs. See [`CODEBOOK.md`](CODEBOOK.md) for variable definitions, summary statistics, and known limitations.

## Notes / limitations

- City finances come from the **2022 Census of Governments** (a full enumeration; non-census years only sample ~140 Texas cities).
- City-name matching between Comptroller and Census reconciles ~97% of cities; ~35 mostly very small cities are absent from the Census finance frame or are duplicate-named places.
- **No fund-balance** variable exists in any free source.
- `population_2022_ref` in the panel is a fixed 2022 reference (free annual city population requires the Census API).
