ACS Variables
An overview of Census ACS variables, particularly related to housing.
The R tidycensus
package is an amazingly simple way to access Census data.1 When you use the package to call Census data, you need to know the variable code for the table or piece of data you’re trying to find. The load_variables()
function allows you to quickly see all variables released in a given year by a survey or program. Census data is well organized and mostly consistent across years.2 This page is meant to help sort through the tens of thousands of variables to find the information you need.
ACS Variables
Variables for the ACS Detailed Tables all begin with the same pattern: a letter (B or C) followed by five digits. The first two digits correspond to a general topic of information, defined in the table below. Variables that start with “C” correspond to a “B” table, but provide more condensed information, such as fewer age groups or income categories. These can be useful when you feel like a graph has too much info and needs to be simplified.
Housing Variables
Housing variables start with “B25”, or “C25” for condensed versions. Sometimes a specific topic will have a lot of different subvariables. For instance, information on tenure (whether a household rents or owns) can be broken down by age, what year the structure was built, etc. I created a directory tree as a simple way to visualize how Census variable relate to each other. The following tree shows top-level ACS 1-Year variables related to housing (excluding condensed variables). The variables that start with “B” are usually also present in the 5-Year ACS.
.
├── Age-Of-Householder
│ ├── C25055-(2005-2022)
│ ├── Gross-Rent-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ │ ├── B25072-(2005-2022)
│ │ └── C25072-(2005-2012)
│ ├── Meals-Included-In-Rent
│ │ └── B25055-(2005-2022)
│ └── Selected-Monthly-Owner-Costs-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ ├── B25093-(2005-2022)
│ └── C25093-(2005-2022)
├── Annual-Other-Fuel-Costs
│ └── B25135-(2021-2022)
├── Annual-Water-And-Sewer-Costs
│ └── B25134-(2021-2022)
├── Average-Household-Size-Of-Occupied-Housing-Units
│ └── Tenure
│ └── B25010-(2005-2022)
├── Bedrooms
│ ├── B25041-(2005-2022)
│ ├── Gross-Rent
│ │ ├── B25068-(2005-2022)
│ │ └── C25068-(2005-2022)
│ └── Occupancy-Status
│ └── B25137-(2022)
├── Contract-Rent
│ ├── B25056-(2005-2022)
│ └── C25056-(2005-2022)
├── Gross-Rent
│ └── B25063-(2005-2022)
├── Gross-Rent-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ └── B25070-(2005-2022)
├── House-Heating-Fuel
│ └── B25040-(2005-2022)
├── Household-Income
│ ├── Gross-Rent-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ │ ├── B25074-(2005-2022)
│ │ └── C25074-(2005-2022)
│ └── Selected-Monthly-Owner-Costs-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ ├── B25095-(2009-2022)
│ └── C25095-(2009-2022)
├── Household-Income-In-The-Past-12-Months-In-Acsyear-Inflation-Adjusted-Dollars
│ ├── Gross-Rent
│ │ ├── B25122-(2005-2022)
│ │ └── C25122-(2005-2022)
│ └── Value
│ ├── B25121-(2005-2022)
│ └── C25121-(2005-2022)
├── Housing-Costs-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ └── B25140-(2022)
├── Housing-Units
│ └── B25001-(2005-2022)
├── Inclusion-Of-Utilities-In-Rent
│ └── B25069-(2005-2022)
├── Kitchen-Facilities
│ ├── C25054-(2005-2012)
│ └── Meals-Included-In-Rent
│ └── B25054-(2005-2022)
├── Kitchen-Facilities-For-All-Housing-Units
│ └── B25051-(2005-2022)
├── Kitchen-Facilities-For-Occupied-Housing-Units
│ └── B25052-(2005-2022)
├── Lower-Contract-Rent-Quartile-Dollars
│ └── B25057-(2005-2022)
├── Lower-Gross-Rent-Quartile-Dollars
│ └── B25138-(2022)
├── Lower-Value-Quartile-Dollars
│ └── B25076-(2005-2022)
├── Median-Contract-Rent-Dollars
│ └── B25058-(2005-2022)
├── Median-Gross-Rent
│ ├── Bedrooms
│ │ └── B25031-(2015-2022)
│ ├── Year-Householder-Moved-Into-Unit
│ │ └── B25113-(2005-2022)
│ └── Year-Structure-Built
│ └── B25111-(2005-2022)
├── Median-Gross-Rent-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months-Dollars
│ └── B25071-(2005-2022)
├── Median-Gross-Rent-Dollars
│ └── B25064-(2005-2022)
├── Median-Household-Income-In-The-Past-12-Months-In-Acsyear-Inflation-Adjusted-Dollars
│ └── Tenure
│ └── B25119-(2005-2022)
├── Median-Monthly-Housing-Costs-Dollars
│ └── B25105-(2005-2022)
├── Median-Number-Of-Rooms
│ ├── B25018-(2005-2022)
│ └── Tenure
│ └── B25021-(2005-2022)
├── Median-Selected-Monthly-Owner-Costs-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ └── B25092-(2005-2022)
├── Median-Selected-Monthly-Owner-Costs-Dollars
│ └── Mortgage-Status
│ └── B25088-(2005-2022)
├── Median-Value
│ ├── Year-Householder-Moved-Into-Unit
│ │ └── B25109-(2005-2022)
│ └── Year-Structure-Built
│ └── B25107-(2005-2022)
├── Median-Value-Dollars
│ └── B25077-(2005-2022)
├── Median-Value-Dollars-For-Mobile-Homes
│ └── B25083-(2005-2022)
├── Median-Year-Householder-Moved-Into-Unit
│ └── Tenure
│ └── B25039-(2005-2022)
├── Median-Year-Structure-Built
│ ├── B25035-(2005-2022)
│ └── Tenure
│ └── B25037-(2005-2022)
├── Monthly-Electricity-Costs
│ └── B25132-(2021-2022)
├── Monthly-Gas-Costs
│ └── B25133-(2021-2022)
├── Monthly-Housing-Costs
│ └── B25104-(2005-2022)
├── Mortgage-Status
│ ├── Age-Of-Householder
│ │ ├── B25027-(2009-2022)
│ │ └── C25027-(2009-2012)
│ ├── B25081-(2005-2022)
│ ├── Household-Income-In-The-Past-12-Months-In-Acsyear-Inflation-Adjusted-Dollars
│ │ └── B25098-(2005-2022)
│ ├── Median-Household-Income-In-The-Past-12-Months-In-Acsyear-Inflation-Adjusted-Dollars
│ │ └── B25099-(2005-2022)
│ ├── Median-Real-Estate-Taxes-Paid-Dollars
│ │ └── B25103-(2005-2022)
│ ├── Median-Value-Dollars
│ │ └── B25097-(2005-2022)
│ ├── Monthly-Housing-Costs-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ │ └── B25101-(2005-2022)
│ ├── Ratio-Of-Value-To-Household-Income-In-The-Past-12-Months
│ │ └── B25100-(2005-2022)
│ ├── Real-Estate-Taxes-Paid
│ │ └── B25102-(2005-2022)
│ ├── Selected-Monthly-Owner-Costs-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ │ └── B25091-(2005-2022)
│ └── Value
│ └── B25096-(2005-2022)
├── Mortgage-Status-And-Selected-Monthly-Owner-Costs
│ └── B25087-(2005-2022)
├── Occupancy-Status
│ └── B25002-(2005-2022)
├── Other-Vacancy-Status
│ └── B25130-(2021-2022)
├── Plumbing-Facilities
│ └── Occupants-Per-Room
│ ├── C25050-(2005-2012)
│ └── Year-Structure-Built
│ └── B25050-(2005-2022)
├── Plumbing-Facilities-For-All-Housing-Units
│ └── B25047-(2005-2022)
├── Plumbing-Facilities-For-Occupied-Housing-Units
│ └── B25048-(2005-2022)
├── Price-Asked
│ ├── B25085-(2005-2022)
│ └── C25085-(2005-2022)
├── Race-Of-Householder
│ └── B25006-(2005-2022)
├── Rent-Asked
│ ├── B25061-(2005-2022)
│ └── C25061-(2005-2012)
├── Rooms
│ └── B25017-(2005-2022)
├── Selected-Monthly-Owner-Costs
│ └── B25094-(2005-2022)
├── Structure-Type
│ └── Occupancy-Status
│ └── B25136-(2022)
├── Tenure
│ ├── Age-Of-Householder
│ │ ├── B25007-(2005-2022)
│ │ ├── Occupants-Per-Room
│ │ │ ├── B25015-(2005-2022)
│ │ │ └── C25015-(2005-2012)
│ │ ├── Units-In-Structure
│ │ │ └── B25125-(2010-2022)
│ │ ├── Year-Householder-Moved-Into-Unit
│ │ │ └── B25128-(2010-2022)
│ │ └── Year-Structure-Built
│ │ └── B25126-(2010-2022)
│ ├── B25003-(2005-2022)
│ ├── Bedrooms
│ │ └── B25042-(2005-2022)
│ ├── Educational-Attainment-Of-Householder
│ │ └── B25013-(2005-2022)
│ ├── Families-And-Presence-Of-Own-Children
│ │ └── B25012-(2005-2022)
│ ├── House-Heating-Fuel
│ │ ├── B25117-(2005-2022)
│ │ └── C25117-(2005-2012)
│ ├── Household-Income-In-The-Past-12-Months-In-Acsyear-Inflation-Adjusted-Dollars
│ │ └── B25118-(2005-2022)
│ ├── Household-Size
│ │ ├── Age-Of-Householder
│ │ │ ├── B25116-(2005-2022)
│ │ │ └── C25116-(2005-2012)
│ │ ├── B25009-(2005-2022)
│ │ └── Units-In-Structure
│ │ └── B25124-(2010-2022)
│ ├── Household-Type
│ │ └── C25115-(2006-2012)
│ ├── Household-Type-And-Presence-And-Age-Of-Own-Children
│ │ ├── B25115-(2005-2022)
│ │ └── C25115-(2005)
│ ├── Household-Type-Including-Living-Alone-And-Age-Of-Householder
│ │ └── B25011-(2005-2022)
│ ├── Housing-Costs-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ │ └── B25106-(2005-2022)
│ ├── Kitchen-Facilities
│ │ └── B25053-(2005-2022)
│ ├── Occupants-Per-Room
│ │ ├── B25014-(2005-2022)
│ │ └── C25014-(2005-2012)
│ ├── Plumbing-Facilities
│ │ ├── B25049-(2005-2022)
│ │ └── Occupants-Per-Room
│ │ ├── B25016-(2005-2022)
│ │ └── C25016-(2005-2012)
│ ├── Rooms
│ │ ├── B25020-(2005-2022)
│ │ └── C25020-(2005-2012)
│ ├── Selected-Physical-And-Financial-Conditions
│ │ ├── B25123-(2005-2022)
│ │ └── C25123-(2005-2012)
│ ├── Telephone-Service-Available
│ │ ├── Age-Of-Householder
│ │ │ ├── B25043-(2005-2022)
│ │ │ └── C25043-(2005)
│ │ └── C25043-(2006-2012)
│ ├── Units-In-Structure
│ │ ├── B25032-(2005-2022)
│ │ └── C25032-(2005-2022)
│ ├── Vehicles-Available
│ │ ├── Age-Of-Householder
│ │ │ └── B25045-(2005-2022)
│ │ ├── B25044-(2005-2022)
│ │ └── C25045-(2005-2022)
│ ├── Year-Householder-Moved-Into-Unit
│ │ ├── B25029-(2010-2011)
│ │ ├── B25038-(2005-2022)
│ │ └── Units-In-Structure
│ │ └── B25129-(2010-2022)
│ └── Year-Structure-Built
│ ├── B25028-(2010-2011)
│ ├── B25036-(2005-2022)
│ └── Units-In-Structure
│ └── B25127-(2010-2022)
├── Total-Population-In-Occupied-Housing-Units
│ └── Tenure
│ ├── B25008-(2005-2022)
│ ├── Units-In-Structure
│ │ ├── B25033-(2005-2022)
│ │ └── C25033-(2005-2022)
│ └── Year-Householder-Moved-Into-Unit
│ └── B25026-(2009-2022)
├── Units-In-Structure
│ ├── B25024-(2005-2022)
│ ├── Bedrooms
│ │ ├── B25029-(2005)
│ │ └── C25029-(2005)
│ ├── C25026-(2005)
│ ├── Gross-Rent-As-A-Percentage-Of-Household-Income-In-The-Past-12-Months
│ │ ├── B25073-(2005-2013)
│ │ └── C25073-(2005-2012)
│ ├── Kitchen-Facilities
│ │ └── B25031-(2005)
│ ├── Plumbing-Facilities
│ │ └── B25030-(2005)
│ ├── Residence-Status
│ │ └── B25026-(2005)
│ ├── Rooms
│ │ ├── B25028-(2005)
│ │ └── C25028-(2005)
│ ├── Vacancy-Status
│ │ ├── B25025-(2005)
│ │ └── C25025-(2005)
│ └── Year-Structure-Built
│ ├── B25027-(2005)
│ └── C25027-(2005)
├── Upper-Contract-Rent-Quartile-Dollars
│ └── B25059-(2005-2022)
├── Upper-Gross-Rent-Quartile-Dollars
│ └── B25139-(2022)
├── Upper-Value-Quartile-Dollars
│ └── B25078-(2005-2022)
├── Vacancy-Duration
│ └── B25131-(2021-2022)
├── Vacancy-Status
│ ├── B25004-(2005-2022)
│ └── C25004-(2005-2022)
├── Vacant-Current-Residence-Elsewhere
│ └── B25005-(2005-2022)
├── Value
│ ├── B25075-(2005-2022)
│ └── C25075-(2006-2022)
└── Year-Structure-Built
└── B25034-(2005-2022)
299 directories, 0 files
How to make the tree
R
First, load the tidyverse and tidycensus packages.
library(tidyverse)
library(tidycensus)
Use the load_variables()
function to get Census variables.
# acs1 data is available from 2005-2022, excluding 2020
<- c(2005:2019, 2021:2022)
years names(years) <- years
# function to load variables for each year, filter for housing
<- function(year, survey) {
get_hsg_vars <- load_variables(year, survey) |>
hsg_vars filter(str_starts(name, "^[BC]25"))
$year <- year
hsg_vars
hsg_vars
}
# Get variables for all years
<- map2(years, "acs1", get_hsg_vars) |> bind_rows() all_hsg_vars
Narrow for housing variables and clean up.
# Get the top level variables
<- all_hsg_vars |>
top_hsg_vars filter(str_detect(name, "_001$"), #' only top-level variables
!str_detect(name, "[:alpha:]_"), #' omit race variables
!str_detect(label, "Estimate!!Aggregate")) |> #' omit aggregates, medians, etc.
mutate(concept =
str_replace_all(concept, c(
"\\b20\\d{2}\\b" = "ACSYEAR", "INCOME THE PAST 12 MONTHS" = "INCOME IN THE PAST 12 MONTHS")) |>
str_to_title()) |>
select(year, name, concept)
Correct for missing variable names from the ACS 2010 and 2011 and create a new column for the year range.
<- filter(top_hsg_vars, year == 2012) |> select(-year)
vars12
# Correct variable names for 2010 and 2011
<- top_hsg_vars |>
top_hsg_vars_fix filter(is.na(concept)) |>
select(-concept) |>
left_join(vars12, by = "name") |>
mutate(concept = case_match(name,
"B25028_001" ~ "Tenure By Year Structure Built",
"B25029_001" ~ "Tenure By Year Householder Moved Into Unit",
.default = concept
))
<- top_hsg_vars |>
hsg_var_years filter(!is.na(concept)) |>
bind_rows(top_hsg_vars_fix) |>
arrange(year, name) |>
mutate(year_range = if_else(
min(year) != max(year), paste0("(", min(year), "-", max(year), ")"), paste0("(", min(year), ")")
.by = c("name", "concept")) |>
), select(-year) |> distinct()
Format for the command line.
<- hsg_var_years |>
hsg_vs mutate(concept = str_replace_all(concept, "-(?=[:alpha:])", " ") |>
str_remove_all("[:punct:]") |>
str_replace_all(" By ", "/"),
name = str_remove(name, "_001")
%>%
) unite(col = "name", name, year_range, sep = "-", na.rm = TRUE) %>%
unite(col = "fileStr", concept, name, sep = "/", na.rm = TRUE) %>%
mutate(fileStr = str_replace_all(fileStr, "\\s", "-"),
fileStr = str_replace_all(fileStr, "-{2,}", "-"))
<- hsg_vs$fileStr
v_ACS1
write_lines(v_ACS1, file = "~/Documents/vACS1.txt")
To make the tree, we will convert this text file to a directory structure.
Command Line
In the terminal, make a new directory to house your Census tree.
mkdir ~/Documents/census
cd Documents/census
Convert the text file to a file directory using the following code.
xargs -I {} mkdir -p "{}" < "../vACS1.txt"
Finally, create a tree of the file directory. Note: requires the tree package.
tree > "../vACStree.txt"
The output is the tree above.
Footnotes
The
tidycensus
package was created by Kyle Walker, and he also published an amazingly helpful book Analyzing US Census Data, which I strongly recommend for anyone interested in accessing Census data with R.↩︎The Census Bureau releases information on which variables have changed from the previous year.↩︎
Citation
@online{johnson2021,
author = {Johnson, Sarah},
title = {ACS {Variables}},
date = {2021-12-24},
url = {https://sarahjohnson.io/posts/variables.html},
langid = {en}
}