Retrieve data from the Census Bureau API in ExcelCensus Bureau API resources:Excel Power Query resources: Cornell PAD resources: Elsewhere:
From data.census.gov to ExcelFor many use cases, a simple download from data.census.gov is sufficient. Downloading as Excel or CSV creates a table that looks very much like the table on your screen. Download as ZIP creates a .zip file with Metadata, annotations and a .csv datafile with variables as columns and geographies as rows. Often this is not the end of the workflow and values for different variables need to be summed and/or geographies need to be combined. Census Bureau's APIsThe Census Bureau APIs (API stands for Application Programming Interface) allow for a very targeted data retrieval. In one API call, you can retrieve data from one or more datatables and precisely define for what geographies. Getting that data into Excel could make the workflow a lot more efficient than working with whole table downloads. Getting results from a single API call into Excel
Getting results from multiple API calls into ExcelA single API lets you retrieve data from a single year and a single data product, for example ACS Detailed tables, ACS Data Profiles or 2020 DHC. The options to combine data retrieval from multiple geogragraphic summary levels in a single API is also limited, for example you can not combine getting data for the state and all counties in the state in a single API. This means that often there is a need for multiple API calls. Another drawback of many workflows described above is that information about where the data originate is not automatically saved with the result. One way to get results from multiple API calls is creating multiple worksheets and repeating the steps above for each worksheet. The Power Query option allows for combining results from multiple sources (API calls). Excel macros can automate some of the steps and the API2Excel Demo Excel file that can be downloaded here is an example of how that could work. API2Excel Demo Excel fileThe ultimate goal of this project was to develop a set of Excel macros that call on the Census Bureau APIs and create a table with a single indicator (direct or derived) from each API call in the columns and a list of geographies as rows.
The worksheet makes it easier to create data profiles, time series, combine geographies and retrieve data from different sources. Because the settings and results are in the same workbook, it is easier to reuse and verify. Some experience with working with the Census Bureau APIs is recommended before starting with this workbook. The workbook itself contains some instruction on how to use it, and so does the presentation given at the 2025 ACS data user conference. In some cases Excel will block macros from running. Microsoft has a page with some things to try to allow this workbook to run. The first step is of course trusting the source and/or scan for malicious code. DISCLAIMER: The workbook can be used freely as-is and further developed for your own purposes. It is a proof of concept and not guaranteed to work under all circumstances. Sharing your work with the data user community is encouraged if you make significant improvements. |