<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Fetching XML data into SAS from API return in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fetching-XML-data-into-SAS-from-API-return/m-p/618284#M181362</link>
    <description>&lt;P&gt;Have exhausted a day trying to extract data that a FCC API returns as xml.&amp;nbsp; The data pull works correctly but I find it impossible to get the data into SAS.&amp;nbsp; I have tried using XML libref as well as trying to read as text.&amp;nbsp; If I read as text and use formats, it will only return first 8 characters when I use proc print.&amp;nbsp; Any hints would be greatly appreciated. Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILENAME ex "f:/prf/Example.xml";&lt;BR /&gt;proc http url='&lt;A href="https://geo.fcc.gov/api/census/block/find?latitude=35&amp;amp;longitude=-100&amp;amp;format=xml" target="_blank" rel="noopener"&gt;https://geo.fcc.gov/api/census/block/find?latitude=35&amp;amp;longitude=-100&amp;amp;format=xml&lt;/A&gt;' /* The base URL */&lt;BR /&gt;method="GET" /* HTTP method used for request */&lt;BR /&gt;out=ex;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data fips; infile ex;&lt;BR /&gt;length one $ 212;informat one $212.;format one $212.;&lt;BR /&gt;input one $;&lt;BR /&gt;put _infile_;&lt;BR /&gt;run;&lt;BR /&gt;proc contents;&lt;BR /&gt;proc print; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which returns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;TABLE border="0" cellspacing="1" cellpadding="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;The SAS System&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Obs one1 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;lt;Response&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Sat, 18 Jan 2020 20:30:40 GMT</pubDate>
    <dc:creator>bkgoodwi</dc:creator>
    <dc:date>2020-01-18T20:30:40Z</dc:date>
    <item>
      <title>Fetching XML data into SAS from API return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetching-XML-data-into-SAS-from-API-return/m-p/618284#M181362</link>
      <description>&lt;P&gt;Have exhausted a day trying to extract data that a FCC API returns as xml.&amp;nbsp; The data pull works correctly but I find it impossible to get the data into SAS.&amp;nbsp; I have tried using XML libref as well as trying to read as text.&amp;nbsp; If I read as text and use formats, it will only return first 8 characters when I use proc print.&amp;nbsp; Any hints would be greatly appreciated. Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FILENAME ex "f:/prf/Example.xml";&lt;BR /&gt;proc http url='&lt;A href="https://geo.fcc.gov/api/census/block/find?latitude=35&amp;amp;longitude=-100&amp;amp;format=xml" target="_blank" rel="noopener"&gt;https://geo.fcc.gov/api/census/block/find?latitude=35&amp;amp;longitude=-100&amp;amp;format=xml&lt;/A&gt;' /* The base URL */&lt;BR /&gt;method="GET" /* HTTP method used for request */&lt;BR /&gt;out=ex;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data fips; infile ex;&lt;BR /&gt;length one $ 212;informat one $212.;format one $212.;&lt;BR /&gt;input one $;&lt;BR /&gt;put _infile_;&lt;BR /&gt;run;&lt;BR /&gt;proc contents;&lt;BR /&gt;proc print; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which returns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;TABLE border="0" cellspacing="1" cellpadding="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;The SAS System&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Obs one1 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;lt;Response&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 18 Jan 2020 20:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetching-XML-data-into-SAS-from-API-return/m-p/618284#M181362</guid>
      <dc:creator>bkgoodwi</dc:creator>
      <dc:date>2020-01-18T20:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching XML data into SAS from API return</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fetching-XML-data-into-SAS-from-API-return/m-p/618310#M181377</link>
      <description>&lt;P&gt;Below works for me.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME response temp;
proc http url='https://geo.fcc.gov/api/census/block/find?latitude=35&amp;amp;longitude=-100&amp;amp;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&amp;amp;docsetTarget=p03yh3krbywig1n1v6lgkuwb3csa.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en */

filename respmap temp;
libname response xmlv2 automap=replace xmlmap=respmap; 

proc contents data=response._all_; 
run;

proc print data=response.county;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Jan 2020 01:51:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fetching-XML-data-into-SAS-from-API-return/m-p/618310#M181377</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-01-19T01:51:19Z</dc:date>
    </item>
  </channel>
</rss>

