Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • New package getcensus on SSC: Load American Community Survey data from the Census Bureau API into Stata

    With thanks to Kit Baum, I’m pleased to share that a new package getcensus is available on SSC.

    getcensus loads American Community Survey (ACS) data from the U.S. Census Bureau API into Stata. It also allows users to search the API data dictionaries for ACS variables and tables of interest. The package requires Stata version 13.1 or later.
    Code:
    ssc install getcensus
    Users may load a single ACS table or a selection of ACS data points into memory by specifying a table ID or list of variable IDs, respectively, to getcensus. Because users rarely know these IDs offhand, getcensus catalog allows users to load the API data dictionaries into memory, optionally filtered by search term.

    Features include:
    • Support for 24 geography types and many geographic components
    • Retrieve data for multiple years with a single command
    • A dialog box for users less familiar with Stata syntax
    The online documentation at https://centeronbudget.github.io/getcensus/ provides a complete description of features and options.

    getcensus uses the Census Bureau Data API but is not endorsed or certified by the Census Bureau.



    Example 1

    Load ACS variables S1701_C02_001 (population in poverty) and S1701_C03_001 (poverty rate) for the state of Virginia (FIPS code 51) for the most recent five years
    Code:
    getcensus S1701_C02_001 S1701_C03_001, years(2015/2019) statefips(51) clear
    A glimpse at the retrieved data:
    Code:
    . list, noobs abbreviate(14)
    
      +---------------------------------------------------------------------------------------------+
      | year   state       name   s1701_c02_001e   s1701_c02_001m   s1701_c03_001e   s1701_c03_001m |
      |---------------------------------------------------------------------------------------------|
      | 2015      51   Virginia           909346            25335             11.2               .3 |
      | 2016      51   Virginia           896440            28235               11               .3 |
      | 2017      51   Virginia           874483            27673             10.6               .3 |
      | 2018      51   Virginia           884647            27692             10.7               .3 |
      | 2019      51   Virginia           822775            24460              9.9               .3 |
      +---------------------------------------------------------------------------------------------+

    By default, data retrieved by getcensus will include metadata from the API data dictionaries as variable labels and notes (shown below).
    Code:
    . notes s1701_c03_001e
     
    s1701_c03_001e:
      1.  Variable: Estimate!!Percent below poverty level!!Population for whom poverty status is
          determined
      2.  Table: POVERTY STATUS IN THE PAST 12 MONTHS
    Example 2

    Load table B19013, median household income, for all zip code tabulation areas in the nation. The option sample(5) specifies five-year estimates, the only type available for ZCTAS.
    Code:
    getcensus B19013, geography(zcta) sample(5) clear
    A glimpse at the retrieved data:
    Code:
    . list in 1/5, noobs abbreviate(21)
    
      +-------------------------------------------------------------------------------------------------+
      | year   state   zipcodetabulationarea           geo_id          name   b19013_001e   b19013_001m |
      |-------------------------------------------------------------------------------------------------|
      | 2019      01                   35004   8600000US35004   ZCTA5 35004         62902          7145 |
      | 2019      01                   35005   8600000US35005   ZCTA5 35005         50473          6548 |
      | 2019      01                   35006   8600000US35006   ZCTA5 35006         55909         11656 |
      | 2019      01                   35007   8600000US35007   ZCTA5 35007         73587          4404 |
      | 2019      01                   35010   8600000US35010   ZCTA5 35010         41954          3441 |
      +-------------------------------------------------------------------------------------------------+
    Example 3

    Load the API data dictionary of every variable whose description matches "educational attainment" in the subject tables ("ST")
    Code:
    getcensus catalog, search(educational attainment) product(ST)
    The first observation of the retrieved dataset:
    Code:
    . list in 1, noobs
    
      +--------------------------------------------------------------------------+
      | table_id |                                  table_name |     variable_id |
      |  S0102PR | POPULATION 60 YEARS AND OVER IN PUERTO RICO | S0102PR_C01_033 |
      |--------------------------------------------------------------------------|
      |                                                       variable_descrip   |
      |  Estimate!!Total!!EDUCATIONAL ATTAINMENT!!Population 25 years and over   |
      +--------------------------------------------------------------------------+
Working...
X