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?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
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.