I am attempting to pull data from a public API using proc http. I will eventually want to feed a file with multiple values to the API and collect the response, but for now I am just trying to understand the mechanics of accessing it so I'm using a static URL. I'm having trouble figuring out how to view my output below.
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;
This appears to run without error, and as I understand it should generate a .json file, but I'm not sure how I can view that/parse it into something useful. I have been getting information on the API from the following source:
https://rxnav.nlm.nih.gov/RxNormAPIs.html#
How can I take my json output (resp) and convert it into a datafile? How can I tell if my call to the API is actually working?
It looks like the response is XML, not JSON.
filename resp '/home/XXXXXXX/Demo1/demo.xml';
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;
libname myfiles xml '/home/XXXXXXX/Demo1/demo.xml';
data ndcstatus;
set myfiles.ndcstatus;
run;
proc print;run;
@A_SAS_Man wrote:
I am attempting to pull data from a public API using proc http. I will eventually want to feed a file with multiple values to the API and collect the response, but for now I am just trying to understand the mechanics of accessing it so I'm using a static URL. I'm having trouble figuring out how to view my output below.
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;This appears to run without error, and as I understand it should generate a .json file, but I'm not sure how I can view that/parse it into something useful. I have been getting information on the API from the following source:
https://rxnav.nlm.nih.gov/RxNormAPIs.html#
How can I take my json output (resp) and convert it into a datafile? How can I tell if my call to the API is actually working?
It looks like the response is XML, not JSON.
filename resp '/home/XXXXXXX/Demo1/demo.xml';
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;
libname myfiles xml '/home/XXXXXXX/Demo1/demo.xml';
data ndcstatus;
set myfiles.ndcstatus;
run;
proc print;run;
@A_SAS_Man wrote:
I am attempting to pull data from a public API using proc http. I will eventually want to feed a file with multiple values to the API and collect the response, but for now I am just trying to understand the mechanics of accessing it so I'm using a static URL. I'm having trouble figuring out how to view my output below.
proc http
method="GET"
url="https://rxnav.nlm.nih.gov/REST/ndcstatus?ndc=00093727356/rxnormdata/ndcStatus/allhistoricalndcs"
out=resp;
run;This appears to run without error, and as I understand it should generate a .json file, but I'm not sure how I can view that/parse it into something useful. I have been getting information on the API from the following source:
https://rxnav.nlm.nih.gov/RxNormAPIs.html#
How can I take my json output (resp) and convert it into a datafile? How can I tell if my call to the API is actually working?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.