BookmarkSubscribeRSS Feed
bkgoodwi
Calcite | Level 5

Have exhausted a day trying to extract data that a FCC API returns as xml.  The data pull works correctly but I find it impossible to get the data into SAS.  I have tried using XML libref as well as trying to read as text.  If I read as text and use formats, it will only return first 8 characters when I use proc print.  Any hints would be greatly appreciated. Here is the code:

 

FILENAME ex "f:/prf/Example.xml";
proc http url='https://geo.fcc.gov/api/census/block/find?latitude=35&longitude=-100&format=xml' /* The base URL */
method="GET" /* HTTP method used for request */
out=ex;
run;

data fips; infile ex;
length one $ 212;informat one $212.;format one $212.;
input one $;
put _infile_;
run;
proc contents;
proc print; run;

 

Which returns

 

The SAS System

Obs one1
<Response
1 REPLY 1
Patrick
Opal | Level 21

Below works for me.

FILENAME response temp;
proc http url='https://geo.fcc.gov/api/census/block/find?latitude=35&longitude=-100&format=xml' /* The base URL */
  method="GET" /* HTTP method used for request */
  out=response;
run;

/* write response xml to SAS log */
data _null_;
  infile response end=last;
  input;
  put _infile_;
run;

/* read response xml into SAS data sets */
/* https://go.documentation.sas.com/?docsetId=engxml&docsetTarget=p03yh3krbywig1n1v6lgkuwb3csa.htm&docsetVersion=9.4&locale=en */

filename respmap temp;
libname response xmlv2 automap=replace xmlmap=respmap; 

proc contents data=response._all_; 
run;

proc print data=response.county;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 1 reply
  • 738 views
  • 0 likes
  • 2 in conversation