BookmarkSubscribeRSS Feed
Jim_Cooper_hmsa
Obsidian | Level 7

I am attempting to create a SAS PROC HTTP query of the Census geocoding API for batch geocoding.  I have been able to get the test API for a single address, but not the batch file processing example.

 

* Geocode Single Address;
proc http
url='https://geocoding.geo.census.gov/geocoder/geographies/address?street=1600+Pennsylvania+Ave&city=Wash...'
in=address
out=geocode;
run;

filename address '//queens.org/FILESHARES/csfs10/CORE01/Core/Geocode/PatientAddresses.csv';
filename geocode '//queens.org/FILESHARES/csfs10/CORE01/Core/Geocode/PatientGeocode.json';

* Batch geocode up to 10,000 addresses in CSV file format;
proc http
url='https://geocoding.geo.census.gov/geocoder/geographies/addressbatch'
in=address
out=geocode;
run;

5 REPLIES 5
ballardw
Super User

What does the LOG show for the batch attempt?

Did you try a "batch" with just one address before attempting 10,000?

Jim_Cooper_hmsa
Obsidian | Level 7
The only response in the log for the PROC HTTP was
NOTE: 500 Internal Server Error

I continue to experiment with the parameters
Jim_Cooper_hmsa
Obsidian | Level 7
The revised log using the DEBUG Level=1 option. I am using the Census geocode API website to construct the code;

https://geocoding.geo.census.gov/geocoder/Geocoding_Services_API.html
73 proc http
74 url="https://geocoding.geo.census.gov/geocoder/geographies/addressbatch"
75 in=address
76 out=geocode;
77 debug level=1;
78 run;
> POST /geocoder/geographies/addressbatch HTTP/1.1
> User-Agent: SAS/9
> Host: geocoding.geo.census.gov
> Accept: */*
> Connection: Keep-Alive
> Content-Length: 4617
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 500
< Date: Wed, 20 Nov 2024 20:06:07 GMT
< Content-Type: text/html;charset=UTF-8
< Connection: keep-alive
< Content-Language: en-US
< Vary: Origin
< Strict-Transport-Security: max-age=31536000
< Set-Cookie:
TS0193e6a1=01283c52a4a4057dae8e2db5c21fd7f5424ca51b75d0807321cf40a8e8c4a6c6ef6d05efdcc30bf3cba57546af422e11772eae5e31; Path=/;
Domain=.geocoding.geo.census.gov; Secure; HttpOnly;
< Transfer-Encoding: chunked
<
NOTE: 500 Internal Server Error
NOTE: PROCEDURE HTTP used (Total process time):
real time 0.21 seconds
cpu time 0.01 seconds




Jim_Cooper_hmsa
Obsidian | Level 7

I emailed the Census Geocoding Support Service and received this response:

Hi Jim,

 

The batch request needs to be sent as multipart/form-data. We aren't sure how to do this in SAS, but hopefully there are examples or documentation you can refer to on how to format the request as multipart/form-data.

 

------------

The example batch file provided on the website is a comma delimited (.csv) file with no header or trailer records.  I'm reviewing the multipart/form-data posts as a possible solution.

mkeintz
PROC Star

@Jim_Cooper_hmsa 

If you end up finding the solution independent of responses to your SAS community topic, I for one would appreciate seeing the solution.  No harm in marking one's own response as a solution.  

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 553 views
  • 0 likes
  • 3 in conversation