ACS Data Users Group

 View Only
  • 1.  Stata error with ACS API

    Posted 01-12-2018 08:36 AM

    Hi all,

    I'm having intermittent trouble using the Census ACS API in Stata 15.0. For a brief period, the API calls were working fine in my office. Now they've stopped working, and when I make the following API call I get the following error message:

    gen str60 B01001_001E = ""

    gen str60 geoname = ""

    gen str60 state = ""

    insheetjson B01001_001E geoname state using "api.census.gov/.../acs1, aoa(1) columns( "1" "2" "3" "4")

    Received fatal alert: handshake_failure
    Error -603, Unable to open URL: file could not be opened
    Warning: No response from source?!?

    * Notes: I've left the API key empty above but am using my personal key in practice. This requires insheetjson.ado and libjson.mlib to be installed.

    I can't tell if it's a Stata issue, firewall issue, or Census server issue. When I past the API directly into a Chrome browser window it works fine, so I suspect it's one of the first two or a combination of the first two.

    I've had trouble just copying files from the Census FTP server within Stata as well. For example, this simple command fails in similar fashion.

    copy "" "mar98supp.zip"

    Received fatal alert: handshake_failure
    r(5100)

    Has anyone else experienced this issue with Stata 15.0, or any recent version for that matter? Or has anyone noticed a change in behavior recently?

    Many thanks,

    Vincent



  • 2.  RE: Stata error with ACS API

    Posted 04-24-2018 05:53 PM
    Hi Vincent,
    I too am having this problem. I receive the same error using Stata 15 on a Windows 10 machine and on a Stata 13 MacOS 10 machine using two different networks.

    Did you or anyone else find a solution?

    -Andrew


  • 3.  RE: Stata error with ACS API

    Posted 04-25-2018 07:22 AM
    Hi ,

    Unfortunately, I did not. My experience has been that I've had issues from both Stata's end and from the Census, and things work one day and break the next.

    One of my colleagues has adapted a work around to use Stata and Python together, where Python makes the connection and retrieves the data, and then Stata reads in the data from a temporary csv stored locally. It's not the best approach, but solves our immediate needs.

    I also use R, which has some pretty robust support for the ACS API, but since I often work with Stata and PUMS I have to reteach myself the packages each time I dip my toes in that world. If you work with ACS summary data a lot, it might be worth looking into those packages ("acs" or "censusapi" come to mind).

    Hope this is helpful,
    Vincent


  • 4.  RE: Stata error with ACS API

    Posted 04-25-2018 07:40 AM
    Thanks, Vincent.


  • 5.  RE: Stata error with ACS API

    Posted 09-07-2021 12:12 PM

    FWIW Stata 17 has the semblance of native support for Python, and I've been using Python to pick up the JSON files from the Census API and pass them as Stata data frames. I can share some code if needed.